11802d0beSThomas Gleixner /* SPDX-License-Identifier: GPL-2.0-only */ 2137c579cSHans Verkuil /* 3137c579cSHans Verkuil * Framework for ISA radio drivers. 4137c579cSHans Verkuil * This takes care of all the V4L2 scaffolding, allowing the ISA drivers 5137c579cSHans Verkuil * to concentrate on the actual hardware operation. 6137c579cSHans Verkuil * 7137c579cSHans Verkuil * Copyright (C) 2012 Hans Verkuil <hans.verkuil@cisco.com> 8137c579cSHans Verkuil */ 9137c579cSHans Verkuil 10137c579cSHans Verkuil #ifndef _RADIO_ISA_H_ 11137c579cSHans Verkuil #define _RADIO_ISA_H_ 12137c579cSHans Verkuil 13137c579cSHans Verkuil #include <linux/isa.h> 14865d7ec9SOndrej Zary #include <linux/pnp.h> 15137c579cSHans Verkuil #include <linux/videodev2.h> 16137c579cSHans Verkuil #include <media/v4l2-device.h> 17137c579cSHans Verkuil #include <media/v4l2-ctrls.h> 18137c579cSHans Verkuil 19137c579cSHans Verkuil struct radio_isa_driver; 20137c579cSHans Verkuil struct radio_isa_ops; 21137c579cSHans Verkuil 22137c579cSHans Verkuil /* Core structure for radio ISA cards */ 23137c579cSHans Verkuil struct radio_isa_card { 24137c579cSHans Verkuil const struct radio_isa_driver *drv; 25137c579cSHans Verkuil struct v4l2_device v4l2_dev; 26137c579cSHans Verkuil struct v4l2_ctrl_handler hdl; 27137c579cSHans Verkuil struct video_device vdev; 28137c579cSHans Verkuil struct mutex lock; 29137c579cSHans Verkuil const struct radio_isa_ops *ops; 30137c579cSHans Verkuil struct { /* mute/volume cluster */ 31137c579cSHans Verkuil struct v4l2_ctrl *mute; 32137c579cSHans Verkuil struct v4l2_ctrl *volume; 33137c579cSHans Verkuil }; 34137c579cSHans Verkuil /* I/O port */ 35137c579cSHans Verkuil int io; 36137c579cSHans Verkuil 37137c579cSHans Verkuil /* Card is in stereo audio mode */ 38137c579cSHans Verkuil bool stereo; 39137c579cSHans Verkuil /* Current frequency */ 40137c579cSHans Verkuil u32 freq; 41137c579cSHans Verkuil }; 42137c579cSHans Verkuil 43137c579cSHans Verkuil struct radio_isa_ops { 44137c579cSHans Verkuil /* Allocate and initialize a radio_isa_card struct */ 45137c579cSHans Verkuil struct radio_isa_card *(*alloc)(void); 46137c579cSHans Verkuil /* Probe whether a card is present at the given port */ 47137c579cSHans Verkuil bool (*probe)(struct radio_isa_card *isa, int io); 48137c579cSHans Verkuil /* Special card initialization can be done here, this is called after 49137c579cSHans Verkuil * the standard controls are registered, but before they are setup, 50137c579cSHans Verkuil * thus allowing drivers to add their own controls here. */ 51137c579cSHans Verkuil int (*init)(struct radio_isa_card *isa); 52137c579cSHans Verkuil /* Set mute and volume. */ 53137c579cSHans Verkuil int (*s_mute_volume)(struct radio_isa_card *isa, bool mute, int volume); 54137c579cSHans Verkuil /* Set frequency */ 55137c579cSHans Verkuil int (*s_frequency)(struct radio_isa_card *isa, u32 freq); 56137c579cSHans Verkuil /* Set stereo/mono audio mode */ 57137c579cSHans Verkuil int (*s_stereo)(struct radio_isa_card *isa, bool stereo); 58137c579cSHans Verkuil /* Get rxsubchans value for VIDIOC_G_TUNER */ 59137c579cSHans Verkuil u32 (*g_rxsubchans)(struct radio_isa_card *isa); 60137c579cSHans Verkuil /* Get the signal strength for VIDIOC_G_TUNER */ 61137c579cSHans Verkuil u32 (*g_signal)(struct radio_isa_card *isa); 62137c579cSHans Verkuil }; 63137c579cSHans Verkuil 64137c579cSHans Verkuil /* Top level structure needed to instantiate the cards */ 65137c579cSHans Verkuil struct radio_isa_driver { 66137c579cSHans Verkuil struct isa_driver driver; 67865d7ec9SOndrej Zary #ifdef CONFIG_PNP 68865d7ec9SOndrej Zary struct pnp_driver pnp_driver; 69865d7ec9SOndrej Zary #endif 70137c579cSHans Verkuil const struct radio_isa_ops *ops; 71137c579cSHans Verkuil /* The module_param_array with the specified I/O ports */ 72137c579cSHans Verkuil int *io_params; 73137c579cSHans Verkuil /* The module_param_array with the radio_nr values */ 74137c579cSHans Verkuil int *radio_nr_params; 75137c579cSHans Verkuil /* Whether we should probe for possible cards */ 76137c579cSHans Verkuil bool probe; 77137c579cSHans Verkuil /* The list of possible I/O ports */ 78137c579cSHans Verkuil const int *io_ports; 79137c579cSHans Verkuil /* The size of that list */ 80137c579cSHans Verkuil int num_of_io_ports; 81137c579cSHans Verkuil /* The region size to request */ 82137c579cSHans Verkuil unsigned region_size; 83137c579cSHans Verkuil /* The name of the card */ 84137c579cSHans Verkuil const char *card; 85137c579cSHans Verkuil /* Card can capture stereo audio */ 86137c579cSHans Verkuil bool has_stereo; 87137c579cSHans Verkuil /* The maximum volume for the volume control. If 0, then there 88137c579cSHans Verkuil is no volume control possible. */ 89137c579cSHans Verkuil int max_volume; 90137c579cSHans Verkuil }; 91137c579cSHans Verkuil 92137c579cSHans Verkuil int radio_isa_match(struct device *pdev, unsigned int dev); 93137c579cSHans Verkuil int radio_isa_probe(struct device *pdev, unsigned int dev); 94*30e88d01SUwe Kleine-König void radio_isa_remove(struct device *pdev, unsigned int dev); 95865d7ec9SOndrej Zary #ifdef CONFIG_PNP 96865d7ec9SOndrej Zary int radio_isa_pnp_probe(struct pnp_dev *dev, 97865d7ec9SOndrej Zary const struct pnp_device_id *dev_id); 98865d7ec9SOndrej Zary void radio_isa_pnp_remove(struct pnp_dev *dev); 99865d7ec9SOndrej Zary #endif 100137c579cSHans Verkuil 101137c579cSHans Verkuil #endif 102