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