radio-isa.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. /*
  2. * Framework for ISA radio drivers.
  3. * This takes care of all the V4L2 scaffolding, allowing the ISA drivers
  4. * to concentrate on the actual hardware operation.
  5. *
  6. * Copyright (C) 2012 Hans Verkuil <hans.verkuil@cisco.com>
  7. *
  8. * This program is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU General Public License
  10. * version 2 as published by the Free Software Foundation.
  11. *
  12. * This program is distributed in the hope that it will be useful, but
  13. * WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15. * General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program; if not, write to the Free Software
  19. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
  20. * 02110-1301 USA
  21. */
  22. #ifndef _RADIO_ISA_H_
  23. #define _RADIO_ISA_H_
  24. #include <linux/isa.h>
  25. #include <linux/pnp.h>
  26. #include <linux/videodev2.h>
  27. #include <media/v4l2-device.h>
  28. #include <media/v4l2-ctrls.h>
  29. struct radio_isa_driver;
  30. struct radio_isa_ops;
  31. /* Core structure for radio ISA cards */
  32. struct radio_isa_card {
  33. const struct radio_isa_driver *drv;
  34. struct v4l2_device v4l2_dev;
  35. struct v4l2_ctrl_handler hdl;
  36. struct video_device vdev;
  37. struct mutex lock;
  38. const struct radio_isa_ops *ops;
  39. struct { /* mute/volume cluster */
  40. struct v4l2_ctrl *mute;
  41. struct v4l2_ctrl *volume;
  42. };
  43. /* I/O port */
  44. int io;
  45. /* Card is in stereo audio mode */
  46. bool stereo;
  47. /* Current frequency */
  48. u32 freq;
  49. };
  50. struct radio_isa_ops {
  51. /* Allocate and initialize a radio_isa_card struct */
  52. struct radio_isa_card *(*alloc)(void);
  53. /* Probe whether a card is present at the given port */
  54. bool (*probe)(struct radio_isa_card *isa, int io);
  55. /* Special card initialization can be done here, this is called after
  56. * the standard controls are registered, but before they are setup,
  57. * thus allowing drivers to add their own controls here. */
  58. int (*init)(struct radio_isa_card *isa);
  59. /* Set mute and volume. */
  60. int (*s_mute_volume)(struct radio_isa_card *isa, bool mute, int volume);
  61. /* Set frequency */
  62. int (*s_frequency)(struct radio_isa_card *isa, u32 freq);
  63. /* Set stereo/mono audio mode */
  64. int (*s_stereo)(struct radio_isa_card *isa, bool stereo);
  65. /* Get rxsubchans value for VIDIOC_G_TUNER */
  66. u32 (*g_rxsubchans)(struct radio_isa_card *isa);
  67. /* Get the signal strength for VIDIOC_G_TUNER */
  68. u32 (*g_signal)(struct radio_isa_card *isa);
  69. };
  70. /* Top level structure needed to instantiate the cards */
  71. struct radio_isa_driver {
  72. struct isa_driver driver;
  73. #ifdef CONFIG_PNP
  74. struct pnp_driver pnp_driver;
  75. #endif
  76. const struct radio_isa_ops *ops;
  77. /* The module_param_array with the specified I/O ports */
  78. int *io_params;
  79. /* The module_param_array with the radio_nr values */
  80. int *radio_nr_params;
  81. /* Whether we should probe for possible cards */
  82. bool probe;
  83. /* The list of possible I/O ports */
  84. const int *io_ports;
  85. /* The size of that list */
  86. int num_of_io_ports;
  87. /* The region size to request */
  88. unsigned region_size;
  89. /* The name of the card */
  90. const char *card;
  91. /* Card can capture stereo audio */
  92. bool has_stereo;
  93. /* The maximum volume for the volume control. If 0, then there
  94. is no volume control possible. */
  95. int max_volume;
  96. };
  97. int radio_isa_match(struct device *pdev, unsigned int dev);
  98. int radio_isa_probe(struct device *pdev, unsigned int dev);
  99. int radio_isa_remove(struct device *pdev, unsigned int dev);
  100. #ifdef CONFIG_PNP
  101. int radio_isa_pnp_probe(struct pnp_dev *dev,
  102. const struct pnp_device_id *dev_id);
  103. void radio_isa_pnp_remove(struct pnp_dev *dev);
  104. #endif
  105. #endif