Lines Matching +full:drv +full:- +full:1

1 // SPDX-License-Identifier: GPL-2.0-only
17 #include <media/v4l2-device.h>
18 #include <media/v4l2-ioctl.h>
19 #include <media/v4l2-fh.h>
20 #include <media/v4l2-ctrls.h>
21 #include <media/v4l2-event.h>
23 #include "radio-isa.h"
37 strscpy(v->driver, isa->drv->driver.driver.name, sizeof(v->driver)); in radio_isa_querycap()
38 strscpy(v->card, isa->drv->card, sizeof(v->card)); in radio_isa_querycap()
39 snprintf(v->bus_info, sizeof(v->bus_info), "ISA:%s", dev_name(isa->v4l2_dev.dev)); in radio_isa_querycap()
47 const struct radio_isa_ops *ops = isa->drv->ops; in radio_isa_g_tuner()
49 if (v->index > 0) in radio_isa_g_tuner()
50 return -EINVAL; in radio_isa_g_tuner()
52 strscpy(v->name, "FM", sizeof(v->name)); in radio_isa_g_tuner()
53 v->type = V4L2_TUNER_RADIO; in radio_isa_g_tuner()
54 v->rangelow = FREQ_LOW; in radio_isa_g_tuner()
55 v->rangehigh = FREQ_HIGH; in radio_isa_g_tuner()
56 v->capability = V4L2_TUNER_CAP_LOW; in radio_isa_g_tuner()
57 if (isa->drv->has_stereo) in radio_isa_g_tuner()
58 v->capability |= V4L2_TUNER_CAP_STEREO; in radio_isa_g_tuner()
60 if (ops->g_rxsubchans) in radio_isa_g_tuner()
61 v->rxsubchans = ops->g_rxsubchans(isa); in radio_isa_g_tuner()
63 v->rxsubchans = V4L2_TUNER_SUB_MONO | V4L2_TUNER_SUB_STEREO; in radio_isa_g_tuner()
64 v->audmode = isa->stereo ? V4L2_TUNER_MODE_STEREO : V4L2_TUNER_MODE_MONO; in radio_isa_g_tuner()
65 if (ops->g_signal) in radio_isa_g_tuner()
66 v->signal = ops->g_signal(isa); in radio_isa_g_tuner()
68 v->signal = (v->rxsubchans & V4L2_TUNER_SUB_STEREO) ? in radio_isa_g_tuner()
77 const struct radio_isa_ops *ops = isa->drv->ops; in radio_isa_s_tuner()
79 if (v->index) in radio_isa_s_tuner()
80 return -EINVAL; in radio_isa_s_tuner()
81 if (ops->s_stereo) { in radio_isa_s_tuner()
82 isa->stereo = (v->audmode == V4L2_TUNER_MODE_STEREO); in radio_isa_s_tuner()
83 return ops->s_stereo(isa, isa->stereo); in radio_isa_s_tuner()
92 u32 freq = f->frequency; in radio_isa_s_frequency()
95 if (f->tuner != 0 || f->type != V4L2_TUNER_RADIO) in radio_isa_s_frequency()
96 return -EINVAL; in radio_isa_s_frequency()
98 res = isa->drv->ops->s_frequency(isa, freq); in radio_isa_s_frequency()
100 isa->freq = freq; in radio_isa_s_frequency()
109 if (f->tuner != 0) in radio_isa_g_frequency()
110 return -EINVAL; in radio_isa_g_frequency()
111 f->type = V4L2_TUNER_RADIO; in radio_isa_g_frequency()
112 f->frequency = isa->freq; in radio_isa_g_frequency()
119 container_of(ctrl->handler, struct radio_isa_card, hdl); in radio_isa_s_ctrl()
121 switch (ctrl->id) { in radio_isa_s_ctrl()
123 return isa->drv->ops->s_mute_volume(isa, ctrl->val, in radio_isa_s_ctrl()
124 isa->volume ? isa->volume->val : 0); in radio_isa_s_ctrl()
126 return -EINVAL; in radio_isa_s_ctrl()
133 v4l2_info(&isa->v4l2_dev, "I/O Port = 0x%03x\n", isa->io); in radio_isa_log_status()
134 v4l2_ctrl_handler_log_status(&isa->hdl, isa->v4l2_dev.name); in radio_isa_log_status()
163 struct radio_isa_driver *drv = pdev->platform_data; in radio_isa_match() local
165 return drv->probe || drv->io_params[dev] >= 0; in radio_isa_match()
169 static bool radio_isa_valid_io(const struct radio_isa_driver *drv, int io) in radio_isa_valid_io() argument
173 for (i = 0; i < drv->num_of_io_ports; i++) in radio_isa_valid_io()
174 if (drv->io_ports[i] == io) in radio_isa_valid_io()
179 static struct radio_isa_card *radio_isa_alloc(struct radio_isa_driver *drv, in radio_isa_alloc() argument
183 struct radio_isa_card *isa = drv->ops->alloc(); in radio_isa_alloc()
188 isa->drv = drv; in radio_isa_alloc()
189 v4l2_dev = &isa->v4l2_dev; in radio_isa_alloc()
190 strscpy(v4l2_dev->name, dev_name(pdev), sizeof(v4l2_dev->name)); in radio_isa_alloc()
199 const struct radio_isa_driver *drv = isa->drv; in radio_isa_common_probe() local
200 const struct radio_isa_ops *ops = drv->ops; in radio_isa_common_probe()
201 struct v4l2_device *v4l2_dev = &isa->v4l2_dev; in radio_isa_common_probe()
204 if (!request_region(isa->io, region_size, v4l2_dev->name)) { in radio_isa_common_probe()
205 v4l2_err(v4l2_dev, "port 0x%x already in use\n", isa->io); in radio_isa_common_probe()
207 return -EBUSY; in radio_isa_common_probe()
216 v4l2_ctrl_handler_init(&isa->hdl, 1); in radio_isa_common_probe()
217 isa->mute = v4l2_ctrl_new_std(&isa->hdl, &radio_isa_ctrl_ops, in radio_isa_common_probe()
218 V4L2_CID_AUDIO_MUTE, 0, 1, 1, 1); in radio_isa_common_probe()
219 if (drv->max_volume) in radio_isa_common_probe()
220 isa->volume = v4l2_ctrl_new_std(&isa->hdl, &radio_isa_ctrl_ops, in radio_isa_common_probe()
221 V4L2_CID_AUDIO_VOLUME, 0, drv->max_volume, 1, in radio_isa_common_probe()
222 drv->max_volume); in radio_isa_common_probe()
223 v4l2_dev->ctrl_handler = &isa->hdl; in radio_isa_common_probe()
224 if (isa->hdl.error) { in radio_isa_common_probe()
225 res = isa->hdl.error; in radio_isa_common_probe()
229 if (drv->max_volume) in radio_isa_common_probe()
230 v4l2_ctrl_cluster(2, &isa->mute); in radio_isa_common_probe()
231 v4l2_dev->ctrl_handler = &isa->hdl; in radio_isa_common_probe()
233 mutex_init(&isa->lock); in radio_isa_common_probe()
234 isa->vdev.lock = &isa->lock; in radio_isa_common_probe()
235 strscpy(isa->vdev.name, v4l2_dev->name, sizeof(isa->vdev.name)); in radio_isa_common_probe()
236 isa->vdev.v4l2_dev = v4l2_dev; in radio_isa_common_probe()
237 isa->vdev.fops = &radio_isa_fops; in radio_isa_common_probe()
238 isa->vdev.ioctl_ops = &radio_isa_ioctl_ops; in radio_isa_common_probe()
239 isa->vdev.release = video_device_release_empty; in radio_isa_common_probe()
240 isa->vdev.device_caps = V4L2_CAP_TUNER | V4L2_CAP_RADIO; in radio_isa_common_probe()
241 video_set_drvdata(&isa->vdev, isa); in radio_isa_common_probe()
242 isa->freq = FREQ_LOW; in radio_isa_common_probe()
243 isa->stereo = drv->has_stereo; in radio_isa_common_probe()
245 if (ops->init) in radio_isa_common_probe()
246 res = ops->init(isa); in radio_isa_common_probe()
248 res = v4l2_ctrl_handler_setup(&isa->hdl); in radio_isa_common_probe()
250 res = ops->s_frequency(isa, isa->freq); in radio_isa_common_probe()
251 if (!res && ops->s_stereo) in radio_isa_common_probe()
252 res = ops->s_stereo(isa, isa->stereo); in radio_isa_common_probe()
257 res = video_register_device(&isa->vdev, VFL_TYPE_RADIO, radio_nr); in radio_isa_common_probe()
265 drv->card, isa->io); in radio_isa_common_probe()
269 v4l2_ctrl_handler_free(&isa->hdl); in radio_isa_common_probe()
271 release_region(isa->io, region_size); in radio_isa_common_probe()
279 const struct radio_isa_ops *ops = isa->drv->ops; in radio_isa_common_remove()
281 ops->s_mute_volume(isa, true, isa->volume ? isa->volume->cur.val : 0); in radio_isa_common_remove()
282 video_unregister_device(&isa->vdev); in radio_isa_common_remove()
283 v4l2_ctrl_handler_free(&isa->hdl); in radio_isa_common_remove()
284 v4l2_device_unregister(&isa->v4l2_dev); in radio_isa_common_remove()
285 release_region(isa->io, region_size); in radio_isa_common_remove()
286 v4l2_info(&isa->v4l2_dev, "Removed radio card %s\n", isa->drv->card); in radio_isa_common_remove()
292 struct radio_isa_driver *drv = pdev->platform_data; in radio_isa_probe() local
293 const struct radio_isa_ops *ops = drv->ops; in radio_isa_probe()
297 isa = radio_isa_alloc(drv, pdev); in radio_isa_probe()
299 return -ENOMEM; in radio_isa_probe()
300 isa->io = drv->io_params[dev]; in radio_isa_probe()
301 v4l2_dev = &isa->v4l2_dev; in radio_isa_probe()
303 if (drv->probe && ops->probe) { in radio_isa_probe()
306 for (i = 0; i < drv->num_of_io_ports; ++i) { in radio_isa_probe()
307 int io = drv->io_ports[i]; in radio_isa_probe()
309 if (request_region(io, drv->region_size, v4l2_dev->name)) { in radio_isa_probe()
310 bool found = ops->probe(isa, io); in radio_isa_probe()
312 release_region(io, drv->region_size); in radio_isa_probe()
314 isa->io = io; in radio_isa_probe()
321 if (!radio_isa_valid_io(drv, isa->io)) { in radio_isa_probe()
324 if (isa->io < 0) in radio_isa_probe()
325 return -ENODEV; in radio_isa_probe()
327 drv->io_ports[0]); in radio_isa_probe()
328 for (i = 1; i < drv->num_of_io_ports; i++) in radio_isa_probe()
329 printk(KERN_CONT "/0x%03x", drv->io_ports[i]); in radio_isa_probe()
332 return -EINVAL; in radio_isa_probe()
335 return radio_isa_common_probe(isa, pdev, drv->radio_nr_params[dev], in radio_isa_probe()
336 drv->region_size); in radio_isa_probe()
344 radio_isa_common_remove(isa, isa->drv->region_size); in radio_isa_remove()
351 struct pnp_driver *pnp_drv = to_pnp_driver(dev->dev.driver); in radio_isa_pnp_probe()
352 struct radio_isa_driver *drv = container_of(pnp_drv, in radio_isa_pnp_probe() local
357 return -ENODEV; in radio_isa_pnp_probe()
359 isa = radio_isa_alloc(drv, &dev->dev); in radio_isa_pnp_probe()
361 return -ENOMEM; in radio_isa_pnp_probe()
363 isa->io = pnp_port_start(dev, 0); in radio_isa_pnp_probe()
365 return radio_isa_common_probe(isa, &dev->dev, drv->radio_nr_params[0], in radio_isa_pnp_probe()
372 struct radio_isa_card *isa = dev_get_drvdata(&dev->dev); in radio_isa_pnp_remove()