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