radio-isa.h 3.0 KB

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