radio-isa.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  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/videodev2.h>
  26. #include <media/v4l2-device.h>
  27. #include <media/v4l2-ctrls.h>
  28. struct radio_isa_driver;
  29. struct radio_isa_ops;
  30. /* Core structure for radio ISA cards */
  31. struct radio_isa_card {
  32. const struct radio_isa_driver *drv;
  33. struct v4l2_device v4l2_dev;
  34. struct v4l2_ctrl_handler hdl;
  35. struct video_device vdev;
  36. struct mutex lock;
  37. const struct radio_isa_ops *ops;
  38. struct { /* mute/volume cluster */
  39. struct v4l2_ctrl *mute;
  40. struct v4l2_ctrl *volume;
  41. };
  42. /* I/O port */
  43. int io;
  44. /* Card is in stereo audio mode */
  45. bool stereo;
  46. /* Current frequency */
  47. u32 freq;
  48. };
  49. struct radio_isa_ops {
  50. /* Allocate and initialize a radio_isa_card struct */
  51. struct radio_isa_card *(*alloc)(void);
  52. /* Probe whether a card is present at the given port */
  53. bool (*probe)(struct radio_isa_card *isa, int io);
  54. /* Special card initialization can be done here, this is called after
  55. * the standard controls are registered, but before they are setup,
  56. * thus allowing drivers to add their own controls here. */
  57. int (*init)(struct radio_isa_card *isa);
  58. /* Set mute and volume. */
  59. int (*s_mute_volume)(struct radio_isa_card *isa, bool mute, int volume);
  60. /* Set frequency */
  61. int (*s_frequency)(struct radio_isa_card *isa, u32 freq);
  62. /* Set stereo/mono audio mode */
  63. int (*s_stereo)(struct radio_isa_card *isa, bool stereo);
  64. /* Get rxsubchans value for VIDIOC_G_TUNER */
  65. u32 (*g_rxsubchans)(struct radio_isa_card *isa);
  66. /* Get the signal strength for VIDIOC_G_TUNER */
  67. u32 (*g_signal)(struct radio_isa_card *isa);
  68. };
  69. /* Top level structure needed to instantiate the cards */
  70. struct radio_isa_driver {
  71. struct isa_driver driver;
  72. const struct radio_isa_ops *ops;
  73. /* The module_param_array with the specified I/O ports */
  74. int *io_params;
  75. /* The module_param_array with the radio_nr values */
  76. int *radio_nr_params;
  77. /* Whether we should probe for possible cards */
  78. bool probe;
  79. /* The list of possible I/O ports */
  80. const int *io_ports;
  81. /* The size of that list */
  82. int num_of_io_ports;
  83. /* The region size to request */
  84. unsigned region_size;
  85. /* The name of the card */
  86. const char *card;
  87. /* Card can capture stereo audio */
  88. bool has_stereo;
  89. /* The maximum volume for the volume control. If 0, then there
  90. is no volume control possible. */
  91. int max_volume;
  92. };
  93. int radio_isa_match(struct device *pdev, unsigned int dev);
  94. int radio_isa_probe(struct device *pdev, unsigned int dev);
  95. int radio_isa_remove(struct device *pdev, unsigned int dev);
  96. #endif