Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-only */
0002 /*
0003  * Framework for ISA radio drivers.
0004  * This takes care of all the V4L2 scaffolding, allowing the ISA drivers
0005  * to concentrate on the actual hardware operation.
0006  *
0007  * Copyright (C) 2012 Hans Verkuil <hans.verkuil@cisco.com>
0008  */
0009 
0010 #ifndef _RADIO_ISA_H_
0011 #define _RADIO_ISA_H_
0012 
0013 #include <linux/isa.h>
0014 #include <linux/pnp.h>
0015 #include <linux/videodev2.h>
0016 #include <media/v4l2-device.h>
0017 #include <media/v4l2-ctrls.h>
0018 
0019 struct radio_isa_driver;
0020 struct radio_isa_ops;
0021 
0022 /* Core structure for radio ISA cards */
0023 struct radio_isa_card {
0024     const struct radio_isa_driver *drv;
0025     struct v4l2_device v4l2_dev;
0026     struct v4l2_ctrl_handler hdl;
0027     struct video_device vdev;
0028     struct mutex lock;
0029     const struct radio_isa_ops *ops;
0030     struct {    /* mute/volume cluster */
0031         struct v4l2_ctrl *mute;
0032         struct v4l2_ctrl *volume;
0033     };
0034     /* I/O port */
0035     int io;
0036 
0037     /* Card is in stereo audio mode */
0038     bool stereo;
0039     /* Current frequency */
0040     u32 freq;
0041 };
0042 
0043 struct radio_isa_ops {
0044     /* Allocate and initialize a radio_isa_card struct */
0045     struct radio_isa_card *(*alloc)(void);
0046     /* Probe whether a card is present at the given port */
0047     bool (*probe)(struct radio_isa_card *isa, int io);
0048     /* Special card initialization can be done here, this is called after
0049      * the standard controls are registered, but before they are setup,
0050      * thus allowing drivers to add their own controls here. */
0051     int (*init)(struct radio_isa_card *isa);
0052     /* Set mute and volume. */
0053     int (*s_mute_volume)(struct radio_isa_card *isa, bool mute, int volume);
0054     /* Set frequency */
0055     int (*s_frequency)(struct radio_isa_card *isa, u32 freq);
0056     /* Set stereo/mono audio mode */
0057     int (*s_stereo)(struct radio_isa_card *isa, bool stereo);
0058     /* Get rxsubchans value for VIDIOC_G_TUNER */
0059     u32 (*g_rxsubchans)(struct radio_isa_card *isa);
0060     /* Get the signal strength for VIDIOC_G_TUNER */
0061     u32 (*g_signal)(struct radio_isa_card *isa);
0062 };
0063 
0064 /* Top level structure needed to instantiate the cards */
0065 struct radio_isa_driver {
0066     struct isa_driver driver;
0067 #ifdef CONFIG_PNP
0068     struct pnp_driver pnp_driver;
0069 #endif
0070     const struct radio_isa_ops *ops;
0071     /* The module_param_array with the specified I/O ports */
0072     int *io_params;
0073     /* The module_param_array with the radio_nr values */
0074     int *radio_nr_params;
0075     /* Whether we should probe for possible cards */
0076     bool probe;
0077     /* The list of possible I/O ports */
0078     const int *io_ports;
0079     /* The size of that list */
0080     int num_of_io_ports;
0081     /* The region size to request */
0082     unsigned region_size;
0083     /* The name of the card */
0084     const char *card;
0085     /* Card can capture stereo audio */
0086     bool has_stereo;
0087     /* The maximum volume for the volume control. If 0, then there
0088        is no volume control possible. */
0089     int max_volume;
0090 };
0091 
0092 int radio_isa_match(struct device *pdev, unsigned int dev);
0093 int radio_isa_probe(struct device *pdev, unsigned int dev);
0094 void radio_isa_remove(struct device *pdev, unsigned int dev);
0095 #ifdef CONFIG_PNP
0096 int radio_isa_pnp_probe(struct pnp_dev *dev,
0097             const struct pnp_device_id *dev_id);
0098 void radio_isa_pnp_remove(struct pnp_dev *dev);
0099 #endif
0100 
0101 #endif