Lines Matching +full:adc +full:- +full:sample +full:- +full:hold +full:- +full:time
1 // SPDX-License-Identifier: GPL-2.0-or-later
9 * (C) 1999-2004 Nemosoft Unv.
10 * (C) 2004-2006 Luc Saillard (luc@saillard.org)
17 #include <media/v4l2-device.h>
18 #include <media/v4l2-ioctl.h>
19 #include <media/v4l2-ctrls.h>
20 #include <media/v4l2-event.h>
22 #include <media/videobuf2-v4l2.h>
23 #include <media/videobuf2-vmalloc.h>
51 /* signed 12-bit */
100 /* common v4l buffer stuff -- must be first */
122 struct usb_device *udev; /* Both mutexes most be hold when setting! */
138 u32 sample; /* for sample rate calc */ member
149 spin_lock_irqsave(&dev->queued_bufs_lock, flags); in msi2500_get_next_fill_buf()
150 if (list_empty(&dev->queued_bufs)) in msi2500_get_next_fill_buf()
153 buf = list_entry(dev->queued_bufs.next, struct msi2500_frame_buf, list); in msi2500_get_next_fill_buf()
154 list_del(&buf->list); in msi2500_get_next_fill_buf()
156 spin_unlock_irqrestore(&dev->queued_bufs_lock, flags); in msi2500_get_next_fill_buf()
162 * | 00-1023 | USB packet type '504'
164 * | 00- 03 | sequence number of first sample in that USB packet
165 * +---------------------------------------------------------------------------
166 * | 04- 15 | garbage
167 * +---------------------------------------------------------------------------
168 * | 16-1023 | samples
169 * +---------------------------------------------------------------------------
170 * signed 8-bit sample
175 * | 00-1023 | USB packet type '384'
177 * | 00- 03 | sequence number of first sample in that USB packet
178 * +---------------------------------------------------------------------------
179 * | 04- 15 | garbage
180 * +---------------------------------------------------------------------------
181 * | 16- 175 | samples
182 * +---------------------------------------------------------------------------
183 * | 176- 179 | control bits for previous samples
184 * +---------------------------------------------------------------------------
185 * | 180- 339 | samples
186 * +---------------------------------------------------------------------------
187 * | 340- 343 | control bits for previous samples
188 * +---------------------------------------------------------------------------
189 * | 344- 503 | samples
190 * +---------------------------------------------------------------------------
191 * | 504- 507 | control bits for previous samples
192 * +---------------------------------------------------------------------------
193 * | 508- 667 | samples
194 * +---------------------------------------------------------------------------
195 * | 668- 671 | control bits for previous samples
196 * +---------------------------------------------------------------------------
197 * | 672- 831 | samples
198 * +---------------------------------------------------------------------------
199 * | 832- 835 | control bits for previous samples
200 * +---------------------------------------------------------------------------
201 * | 836- 995 | samples
202 * +---------------------------------------------------------------------------
203 * | 996- 999 | control bits for previous samples
204 * +---------------------------------------------------------------------------
205 * | 1000-1023 | garbage
206 * +---------------------------------------------------------------------------
208 * Bytes 4 - 7 could have some meaning?
210 * Control bits for previous samples is 32-bit field, containing 16 x 2-bit
211 * numbers. This results one 2-bit number for 8 samples. It is likely used for
212 * bit shifting sample by given bits, increasing actual sampling resolution.
219 * | 00-1023 | USB packet type '336'
221 * | 00- 03 | sequence number of first sample in that USB packet
222 * +---------------------------------------------------------------------------
223 * | 04- 15 | garbage
224 * +---------------------------------------------------------------------------
225 * | 16-1023 | samples
226 * +---------------------------------------------------------------------------
227 * signed 12-bit sample
231 * | 00-1023 | USB packet type '252'
233 * | 00- 03 | sequence number of first sample in that USB packet
234 * +---------------------------------------------------------------------------
235 * | 04- 15 | garbage
236 * +---------------------------------------------------------------------------
237 * | 16-1023 | samples
238 * +---------------------------------------------------------------------------
239 * signed 14-bit sample
246 u32 sample[3]; in msi2500_convert_stream() local
248 /* There could be 1-3 1024 byte transactions per packet */ in msi2500_convert_stream()
252 sample[i] = src[3] << 24 | src[2] << 16 | src[1] << 8 | in msi2500_convert_stream()
254 if (i == 0 && dev->next_sample != sample[0]) { in msi2500_convert_stream()
255 dev_dbg_ratelimited(dev->dev, in msi2500_convert_stream()
257 sample[0] - dev->next_sample, in msi2500_convert_stream()
258 src_len, dev->next_sample, in msi2500_convert_stream()
259 sample[0]); in msi2500_convert_stream()
263 * Dump all unknown 'garbage' data - maybe we will discover in msi2500_convert_stream()
266 dev_dbg_ratelimited(dev->dev, "%*ph\n", 12, &src[4]); in msi2500_convert_stream()
270 switch (dev->pixelformat) { in msi2500_convert_stream()
282 dev->next_sample = sample[i] + 504; in msi2500_convert_stream()
293 /* sign extension from 14-bit to signed int */ in msi2500_convert_stream()
297 /* from 14-bit to 16-bit */ in msi2500_convert_stream()
304 dev->next_sample = sample[i] + 252; in msi2500_convert_stream()
309 dev_dbg_ratelimited(dev->dev, "%*ph\n", 24, &src[1000]); in msi2500_convert_stream()
314 dev->next_sample = sample[i] + 384; in msi2500_convert_stream()
321 dev->next_sample = sample[i] + 504; in msi2500_convert_stream()
328 dev->next_sample = sample[i] + 336; in msi2500_convert_stream()
335 dev->next_sample = sample[i] + 252; in msi2500_convert_stream()
342 /* calculate sample rate and output it in 10 seconds intervals */ in msi2500_convert_stream()
343 if (unlikely(time_is_before_jiffies(dev->jiffies_next))) { in msi2500_convert_stream()
345 unsigned int msecs = jiffies_to_msecs(jiffies - in msi2500_convert_stream()
346 dev->jiffies_next + msecs_to_jiffies(MSECS)); in msi2500_convert_stream()
347 unsigned int samples = dev->next_sample - dev->sample; in msi2500_convert_stream()
349 dev->jiffies_next = jiffies + msecs_to_jiffies(MSECS); in msi2500_convert_stream()
350 dev->sample = dev->next_sample; in msi2500_convert_stream()
351 dev_dbg(dev->dev, "size=%u samples=%u msecs=%u sample rate=%lu\n", in msi2500_convert_stream()
361 * time, so it has to be fast, not crash, and not stall. Neat.
365 struct msi2500_dev *dev = (struct msi2500_dev *)urb->context; in msi2500_isoc_handler()
370 if (unlikely(urb->status == -ENOENT || in msi2500_isoc_handler()
371 urb->status == -ECONNRESET || in msi2500_isoc_handler()
372 urb->status == -ESHUTDOWN)) { in msi2500_isoc_handler()
373 dev_dbg(dev->dev, "URB (%p) unlinked %ssynchronously\n", in msi2500_isoc_handler()
374 urb, urb->status == -ENOENT ? "" : "a"); in msi2500_isoc_handler()
378 if (unlikely(urb->status != 0)) { in msi2500_isoc_handler()
379 dev_dbg(dev->dev, "called with status %d\n", urb->status); in msi2500_isoc_handler()
381 if (++dev->isoc_errors > MAX_ISOC_ERRORS) in msi2500_isoc_handler()
382 dev_dbg(dev->dev, "Too many ISOC errors, bailing out\n"); in msi2500_isoc_handler()
386 dev->isoc_errors = 0; in msi2500_isoc_handler()
390 for (i = 0; i < urb->number_of_packets; i++) { in msi2500_isoc_handler()
394 fstatus = urb->iso_frame_desc[i].status; in msi2500_isoc_handler()
396 dev_dbg_ratelimited(dev->dev, in msi2500_isoc_handler()
398 i, urb->number_of_packets, fstatus); in msi2500_isoc_handler()
403 flen = urb->iso_frame_desc[i].actual_length; in msi2500_isoc_handler()
407 iso_buf = urb->transfer_buffer + urb->iso_frame_desc[i].offset; in msi2500_isoc_handler()
412 dev->vb_full++; in msi2500_isoc_handler()
413 dev_dbg_ratelimited(dev->dev, in msi2500_isoc_handler()
415 dev->vb_full); in msi2500_isoc_handler()
420 ptr = vb2_plane_vaddr(&fbuf->vb.vb2_buf, 0); in msi2500_isoc_handler()
422 vb2_set_plane_payload(&fbuf->vb.vb2_buf, 0, flen); in msi2500_isoc_handler()
423 vb2_buffer_done(&fbuf->vb.vb2_buf, VB2_BUF_STATE_DONE); in msi2500_isoc_handler()
429 dev_dbg(dev->dev, "Error (%d) re-submitting urb\n", i); in msi2500_isoc_handler()
436 dev_dbg(dev->dev, "\n"); in msi2500_iso_stop()
440 if (dev->urbs[i]) { in msi2500_iso_stop()
441 dev_dbg(dev->dev, "Unlinking URB %p\n", dev->urbs[i]); in msi2500_iso_stop()
442 usb_kill_urb(dev->urbs[i]); in msi2500_iso_stop()
451 dev_dbg(dev->dev, "\n"); in msi2500_iso_free()
455 if (dev->urbs[i]) { in msi2500_iso_free()
456 dev_dbg(dev->dev, "Freeing URB\n"); in msi2500_iso_free()
457 if (dev->urbs[i]->transfer_buffer) { in msi2500_iso_free()
458 usb_free_coherent(dev->udev, in msi2500_iso_free()
459 dev->urbs[i]->transfer_buffer_length, in msi2500_iso_free()
460 dev->urbs[i]->transfer_buffer, in msi2500_iso_free()
461 dev->urbs[i]->transfer_dma); in msi2500_iso_free()
463 usb_free_urb(dev->urbs[i]); in msi2500_iso_free()
464 dev->urbs[i] = NULL; in msi2500_iso_free()
472 dev_dbg(dev->dev, "\n"); in msi2500_isoc_cleanup()
484 dev_dbg(dev->dev, "\n"); in msi2500_isoc_init()
486 dev->isoc_errors = 0; in msi2500_isoc_init()
488 ret = usb_set_interface(dev->udev, 0, 1); in msi2500_isoc_init()
497 return -ENOMEM; in msi2500_isoc_init()
499 dev->urbs[i] = urb; in msi2500_isoc_init()
500 dev_dbg(dev->dev, "Allocated URB at 0x%p\n", urb); in msi2500_isoc_init()
502 urb->interval = 1; in msi2500_isoc_init()
503 urb->dev = dev->udev; in msi2500_isoc_init()
504 urb->pipe = usb_rcvisocpipe(dev->udev, 0x81); in msi2500_isoc_init()
505 urb->transfer_flags = URB_ISO_ASAP | URB_NO_TRANSFER_DMA_MAP; in msi2500_isoc_init()
506 urb->transfer_buffer = usb_alloc_coherent(dev->udev, in msi2500_isoc_init()
508 GFP_KERNEL, &urb->transfer_dma); in msi2500_isoc_init()
509 if (urb->transfer_buffer == NULL) { in msi2500_isoc_init()
510 dev_err(dev->dev, in msi2500_isoc_init()
513 return -ENOMEM; in msi2500_isoc_init()
515 urb->transfer_buffer_length = ISO_BUFFER_SIZE; in msi2500_isoc_init()
516 urb->complete = msi2500_isoc_handler; in msi2500_isoc_init()
517 urb->context = dev; in msi2500_isoc_init()
518 urb->start_frame = 0; in msi2500_isoc_init()
519 urb->number_of_packets = ISO_FRAMES_PER_DESC; in msi2500_isoc_init()
521 urb->iso_frame_desc[j].offset = j * ISO_MAX_FRAME_SIZE; in msi2500_isoc_init()
522 urb->iso_frame_desc[j].length = ISO_MAX_FRAME_SIZE; in msi2500_isoc_init()
528 ret = usb_submit_urb(dev->urbs[i], GFP_KERNEL); in msi2500_isoc_init()
530 dev_err(dev->dev, in msi2500_isoc_init()
536 dev_dbg(dev->dev, "URB 0x%p submitted.\n", dev->urbs[i]); in msi2500_isoc_init()
543 /* Must be called with vb_queue_lock hold */
548 dev_dbg(dev->dev, "\n"); in msi2500_cleanup_queued_bufs()
550 spin_lock_irqsave(&dev->queued_bufs_lock, flags); in msi2500_cleanup_queued_bufs()
551 while (!list_empty(&dev->queued_bufs)) { in msi2500_cleanup_queued_bufs()
554 buf = list_entry(dev->queued_bufs.next, in msi2500_cleanup_queued_bufs()
556 list_del(&buf->list); in msi2500_cleanup_queued_bufs()
557 vb2_buffer_done(&buf->vb.vb2_buf, VB2_BUF_STATE_ERROR); in msi2500_cleanup_queued_bufs()
559 spin_unlock_irqrestore(&dev->queued_bufs_lock, flags); in msi2500_cleanup_queued_bufs()
569 dev_dbg(dev->dev, "\n"); in msi2500_disconnect()
571 mutex_lock(&dev->vb_queue_lock); in msi2500_disconnect()
572 mutex_lock(&dev->v4l2_lock); in msi2500_disconnect()
574 dev->udev = NULL; in msi2500_disconnect()
575 v4l2_device_disconnect(&dev->v4l2_dev); in msi2500_disconnect()
576 video_unregister_device(&dev->vdev); in msi2500_disconnect()
577 spi_unregister_master(dev->master); in msi2500_disconnect()
578 mutex_unlock(&dev->v4l2_lock); in msi2500_disconnect()
579 mutex_unlock(&dev->vb_queue_lock); in msi2500_disconnect()
581 v4l2_device_put(&dev->v4l2_dev); in msi2500_disconnect()
589 dev_dbg(dev->dev, "\n"); in msi2500_querycap()
591 strscpy(cap->driver, KBUILD_MODNAME, sizeof(cap->driver)); in msi2500_querycap()
592 strscpy(cap->card, dev->vdev.name, sizeof(cap->card)); in msi2500_querycap()
593 usb_make_path(dev->udev, cap->bus_info, sizeof(cap->bus_info)); in msi2500_querycap()
605 dev_dbg(dev->dev, "nbuffers=%d\n", *nbuffers); in msi2500_queue_setup()
610 sizes[0] = PAGE_ALIGN(dev->buffersize); in msi2500_queue_setup()
611 dev_dbg(dev->dev, "nbuffers=%d sizes[0]=%d\n", *nbuffers, sizes[0]); in msi2500_queue_setup()
618 struct msi2500_dev *dev = vb2_get_drv_priv(vb->vb2_queue); in msi2500_buf_queue()
625 if (unlikely(!dev->udev)) { in msi2500_buf_queue()
626 vb2_buffer_done(&buf->vb.vb2_buf, VB2_BUF_STATE_ERROR); in msi2500_buf_queue()
630 spin_lock_irqsave(&dev->queued_bufs_lock, flags); in msi2500_buf_queue()
631 list_add_tail(&buf->list, &dev->queued_bufs); in msi2500_buf_queue()
632 spin_unlock_irqrestore(&dev->queued_bufs_lock, flags); in msi2500_buf_queue()
659 msi2500_dbg_usb_control_msg(dev->dev, request, requesttype, in msi2500_ctrl_msg()
661 ret = usb_control_msg(dev->udev, usb_sndctrlpipe(dev->udev, 0), request, in msi2500_ctrl_msg()
664 dev_err(dev->dev, "failed %d, cmd %02x, data %04x\n", in msi2500_ctrl_msg()
678 f_sr = dev->f_adc; in msi2500_set_usb_adc()
681 bandwidth_auto = v4l2_ctrl_find(&dev->hdl, in msi2500_set_usb_adc()
684 bandwidth = v4l2_ctrl_find(&dev->hdl, in msi2500_set_usb_adc()
686 v4l2_ctrl_s_ctrl(bandwidth, dev->f_adc); in msi2500_set_usb_adc()
690 switch (dev->pixelformat) { in msi2500_set_usb_adc()
715 * Fractional-N synthesizer in msi2500_set_usb_adc()
717 * +----------------------------------------+ in msi2500_set_usb_adc()
719 * Fref +----+ +-------+ +-----+ +------+ +---+ in msi2500_set_usb_adc()
720 * ------> | PD | --> | VCO | --> | /2 | ------> | /N.F | <-- | K | in msi2500_set_usb_adc()
721 * +----+ +-------+ +-----+ +------+ +---+ in msi2500_set_usb_adc()
725 * +-------+ +-----+ Fout in msi2500_set_usb_adc()
726 * | /Rout | --> | /12 | ------> in msi2500_set_usb_adc()
727 * +-------+ +-----+ in msi2500_set_usb_adc()
745 * 0 - (invalid) in msi2500_set_usb_adc()
754 * VCO 202000000 - 720000000++ in msi2500_set_usb_adc()
775 dev_dbg(dev->dev, "div_out=%u f_vco=%u\n", div_out, f_vco); in msi2500_set_usb_adc()
785 reg3 |= (div_out / 2 - 1) << 10; in msi2500_set_usb_adc()
789 dev_dbg(dev->dev, in msi2500_set_usb_adc()
831 dev_dbg(dev->dev, "\n"); in msi2500_start_streaming()
833 if (!dev->udev) in msi2500_start_streaming()
834 return -ENODEV; in msi2500_start_streaming()
836 if (mutex_lock_interruptible(&dev->v4l2_lock)) in msi2500_start_streaming()
837 return -ERESTARTSYS; in msi2500_start_streaming()
839 /* wake-up tuner */ in msi2500_start_streaming()
840 v4l2_subdev_call(dev->v4l2_subdev, core, s_power, 1); in msi2500_start_streaming()
850 mutex_unlock(&dev->v4l2_lock); in msi2500_start_streaming()
859 dev_dbg(dev->dev, "\n"); in msi2500_stop_streaming()
861 mutex_lock(&dev->v4l2_lock); in msi2500_stop_streaming()
863 if (dev->udev) in msi2500_stop_streaming()
870 if (dev->udev && !msi2500_ctrl_msg(dev, CMD_STOP_STREAMING, 0)) { in msi2500_stop_streaming()
871 /* sleep USB IF / ADC */ in msi2500_stop_streaming()
876 v4l2_subdev_call(dev->v4l2_subdev, core, s_power, 0); in msi2500_stop_streaming()
878 mutex_unlock(&dev->v4l2_lock); in msi2500_stop_streaming()
895 dev_dbg(dev->dev, "index=%d\n", f->index); in msi2500_enum_fmt_sdr_cap()
897 if (f->index >= dev->num_formats) in msi2500_enum_fmt_sdr_cap()
898 return -EINVAL; in msi2500_enum_fmt_sdr_cap()
900 f->pixelformat = formats[f->index].pixelformat; in msi2500_enum_fmt_sdr_cap()
910 dev_dbg(dev->dev, "pixelformat fourcc %4.4s\n", in msi2500_g_fmt_sdr_cap()
911 (char *)&dev->pixelformat); in msi2500_g_fmt_sdr_cap()
913 f->fmt.sdr.pixelformat = dev->pixelformat; in msi2500_g_fmt_sdr_cap()
914 f->fmt.sdr.buffersize = dev->buffersize; in msi2500_g_fmt_sdr_cap()
923 struct vb2_queue *q = &dev->vb_queue; in msi2500_s_fmt_sdr_cap()
926 dev_dbg(dev->dev, "pixelformat fourcc %4.4s\n", in msi2500_s_fmt_sdr_cap()
927 (char *)&f->fmt.sdr.pixelformat); in msi2500_s_fmt_sdr_cap()
930 return -EBUSY; in msi2500_s_fmt_sdr_cap()
932 for (i = 0; i < dev->num_formats; i++) { in msi2500_s_fmt_sdr_cap()
933 if (formats[i].pixelformat == f->fmt.sdr.pixelformat) { in msi2500_s_fmt_sdr_cap()
934 dev->pixelformat = formats[i].pixelformat; in msi2500_s_fmt_sdr_cap()
935 dev->buffersize = formats[i].buffersize; in msi2500_s_fmt_sdr_cap()
936 f->fmt.sdr.buffersize = formats[i].buffersize; in msi2500_s_fmt_sdr_cap()
941 dev->pixelformat = formats[0].pixelformat; in msi2500_s_fmt_sdr_cap()
942 dev->buffersize = formats[0].buffersize; in msi2500_s_fmt_sdr_cap()
943 f->fmt.sdr.pixelformat = formats[0].pixelformat; in msi2500_s_fmt_sdr_cap()
944 f->fmt.sdr.buffersize = formats[0].buffersize; in msi2500_s_fmt_sdr_cap()
955 dev_dbg(dev->dev, "pixelformat fourcc %4.4s\n", in msi2500_try_fmt_sdr_cap()
956 (char *)&f->fmt.sdr.pixelformat); in msi2500_try_fmt_sdr_cap()
958 for (i = 0; i < dev->num_formats; i++) { in msi2500_try_fmt_sdr_cap()
959 if (formats[i].pixelformat == f->fmt.sdr.pixelformat) { in msi2500_try_fmt_sdr_cap()
960 f->fmt.sdr.buffersize = formats[i].buffersize; in msi2500_try_fmt_sdr_cap()
965 f->fmt.sdr.pixelformat = formats[0].pixelformat; in msi2500_try_fmt_sdr_cap()
966 f->fmt.sdr.buffersize = formats[0].buffersize; in msi2500_try_fmt_sdr_cap()
977 dev_dbg(dev->dev, "index=%d\n", v->index); in msi2500_s_tuner()
979 if (v->index == 0) in msi2500_s_tuner()
981 else if (v->index == 1) in msi2500_s_tuner()
982 ret = v4l2_subdev_call(dev->v4l2_subdev, tuner, s_tuner, v); in msi2500_s_tuner()
984 ret = -EINVAL; in msi2500_s_tuner()
994 dev_dbg(dev->dev, "index=%d\n", v->index); in msi2500_g_tuner()
996 if (v->index == 0) { in msi2500_g_tuner()
997 strscpy(v->name, "Mirics MSi2500", sizeof(v->name)); in msi2500_g_tuner()
998 v->type = V4L2_TUNER_ADC; in msi2500_g_tuner()
999 v->capability = V4L2_TUNER_CAP_1HZ | V4L2_TUNER_CAP_FREQ_BANDS; in msi2500_g_tuner()
1000 v->rangelow = 1200000; in msi2500_g_tuner()
1001 v->rangehigh = 15000000; in msi2500_g_tuner()
1003 } else if (v->index == 1) { in msi2500_g_tuner()
1004 ret = v4l2_subdev_call(dev->v4l2_subdev, tuner, g_tuner, v); in msi2500_g_tuner()
1006 ret = -EINVAL; in msi2500_g_tuner()
1018 dev_dbg(dev->dev, "tuner=%d type=%d\n", f->tuner, f->type); in msi2500_g_frequency()
1020 if (f->tuner == 0) { in msi2500_g_frequency()
1021 f->frequency = dev->f_adc; in msi2500_g_frequency()
1023 } else if (f->tuner == 1) { in msi2500_g_frequency()
1024 f->type = V4L2_TUNER_RF; in msi2500_g_frequency()
1025 ret = v4l2_subdev_call(dev->v4l2_subdev, tuner, g_frequency, f); in msi2500_g_frequency()
1027 ret = -EINVAL; in msi2500_g_frequency()
1039 dev_dbg(dev->dev, "tuner=%d type=%d frequency=%u\n", in msi2500_s_frequency()
1040 f->tuner, f->type, f->frequency); in msi2500_s_frequency()
1042 if (f->tuner == 0) { in msi2500_s_frequency()
1043 dev->f_adc = clamp_t(unsigned int, f->frequency, in msi2500_s_frequency()
1046 dev_dbg(dev->dev, "ADC frequency=%u Hz\n", dev->f_adc); in msi2500_s_frequency()
1048 } else if (f->tuner == 1) { in msi2500_s_frequency()
1049 ret = v4l2_subdev_call(dev->v4l2_subdev, tuner, s_frequency, f); in msi2500_s_frequency()
1051 ret = -EINVAL; in msi2500_s_frequency()
1063 dev_dbg(dev->dev, "tuner=%d type=%d index=%d\n", in msi2500_enum_freq_bands()
1064 band->tuner, band->type, band->index); in msi2500_enum_freq_bands()
1066 if (band->tuner == 0) { in msi2500_enum_freq_bands()
1067 if (band->index >= ARRAY_SIZE(bands)) { in msi2500_enum_freq_bands()
1068 ret = -EINVAL; in msi2500_enum_freq_bands()
1070 *band = bands[band->index]; in msi2500_enum_freq_bands()
1073 } else if (band->tuner == 1) { in msi2500_enum_freq_bands()
1074 ret = v4l2_subdev_call(dev->v4l2_subdev, tuner, in msi2500_enum_freq_bands()
1077 ret = -EINVAL; in msi2500_enum_freq_bands()
1134 v4l2_ctrl_handler_free(&dev->hdl); in msi2500_video_release()
1135 v4l2_device_unregister(&dev->v4l2_dev); in msi2500_video_release()
1147 list_for_each_entry(t, &m->transfers, transfer_list) { in msi2500_transfer_one_message()
1148 dev_dbg(dev->dev, "msg=%*ph\n", t->len, t->tx_buf); in msi2500_transfer_one_message()
1150 data |= ((u8 *)t->tx_buf)[0] << 8; in msi2500_transfer_one_message()
1151 data |= ((u8 *)t->tx_buf)[1] << 16; in msi2500_transfer_one_message()
1152 data |= ((u8 *)t->tx_buf)[2] << 24; in msi2500_transfer_one_message()
1156 m->status = ret; in msi2500_transfer_one_message()
1177 ret = -ENOMEM; in msi2500_probe()
1181 mutex_init(&dev->v4l2_lock); in msi2500_probe()
1182 mutex_init(&dev->vb_queue_lock); in msi2500_probe()
1183 spin_lock_init(&dev->queued_bufs_lock); in msi2500_probe()
1184 INIT_LIST_HEAD(&dev->queued_bufs); in msi2500_probe()
1185 dev->dev = &intf->dev; in msi2500_probe()
1186 dev->udev = interface_to_usbdev(intf); in msi2500_probe()
1187 dev->f_adc = bands[0].rangelow; in msi2500_probe()
1188 dev->pixelformat = formats[0].pixelformat; in msi2500_probe()
1189 dev->buffersize = formats[0].buffersize; in msi2500_probe()
1190 dev->num_formats = NUM_FORMATS; in msi2500_probe()
1192 dev->num_formats -= 2; in msi2500_probe()
1195 dev->vb_queue.type = V4L2_BUF_TYPE_SDR_CAPTURE; in msi2500_probe()
1196 dev->vb_queue.io_modes = VB2_MMAP | VB2_USERPTR | VB2_READ; in msi2500_probe()
1197 dev->vb_queue.drv_priv = dev; in msi2500_probe()
1198 dev->vb_queue.buf_struct_size = sizeof(struct msi2500_frame_buf); in msi2500_probe()
1199 dev->vb_queue.ops = &msi2500_vb2_ops; in msi2500_probe()
1200 dev->vb_queue.mem_ops = &vb2_vmalloc_memops; in msi2500_probe()
1201 dev->vb_queue.timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC; in msi2500_probe()
1202 ret = vb2_queue_init(&dev->vb_queue); in msi2500_probe()
1204 dev_err(dev->dev, "Could not initialize vb2 queue\n"); in msi2500_probe()
1209 dev->vdev = msi2500_template; in msi2500_probe()
1210 dev->vdev.queue = &dev->vb_queue; in msi2500_probe()
1211 dev->vdev.queue->lock = &dev->vb_queue_lock; in msi2500_probe()
1212 video_set_drvdata(&dev->vdev, dev); in msi2500_probe()
1215 dev->v4l2_dev.release = msi2500_video_release; in msi2500_probe()
1216 ret = v4l2_device_register(&intf->dev, &dev->v4l2_dev); in msi2500_probe()
1218 dev_err(dev->dev, "Failed to register v4l2-device (%d)\n", ret); in msi2500_probe()
1223 master = spi_alloc_master(dev->dev, 0); in msi2500_probe()
1225 ret = -ENOMEM; in msi2500_probe()
1229 dev->master = master; in msi2500_probe()
1230 master->bus_num = -1; in msi2500_probe()
1231 master->num_chipselect = 1; in msi2500_probe()
1232 master->transfer_one_message = msi2500_transfer_one_message; in msi2500_probe()
1241 sd = v4l2_spi_new_subdev(&dev->v4l2_dev, master, &board_info); in msi2500_probe()
1242 dev->v4l2_subdev = sd; in msi2500_probe()
1244 dev_err(dev->dev, "cannot get v4l2 subdevice\n"); in msi2500_probe()
1245 ret = -ENODEV; in msi2500_probe()
1250 v4l2_ctrl_handler_init(&dev->hdl, 0); in msi2500_probe()
1251 if (dev->hdl.error) { in msi2500_probe()
1252 ret = dev->hdl.error; in msi2500_probe()
1253 dev_err(dev->dev, "Could not initialize controls\n"); in msi2500_probe()
1258 v4l2_ctrl_add_handler(&dev->hdl, sd->ctrl_handler, NULL, true); in msi2500_probe()
1260 dev->v4l2_dev.ctrl_handler = &dev->hdl; in msi2500_probe()
1261 dev->vdev.v4l2_dev = &dev->v4l2_dev; in msi2500_probe()
1262 dev->vdev.lock = &dev->v4l2_lock; in msi2500_probe()
1263 dev->vdev.device_caps = V4L2_CAP_SDR_CAPTURE | V4L2_CAP_STREAMING | in msi2500_probe()
1266 ret = video_register_device(&dev->vdev, VFL_TYPE_SDR, -1); in msi2500_probe()
1268 dev_err(dev->dev, in msi2500_probe()
1272 dev_info(dev->dev, "Registered as %s\n", in msi2500_probe()
1273 video_device_node_name(&dev->vdev)); in msi2500_probe()
1274 dev_notice(dev->dev, in msi2500_probe()
1278 v4l2_ctrl_handler_free(&dev->hdl); in msi2500_probe()
1280 spi_unregister_master(dev->master); in msi2500_probe()
1282 v4l2_device_unregister(&dev->v4l2_dev); in msi2500_probe()