radio-isa.h 3.4 KB

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