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