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