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