Lines Matching refs:zr
165 static int zoran_v4l_set_format(struct zoran *zr, int width, int height, in zoran_v4l_set_format() argument
174 pci_dbg(zr->pci_dev, "%s - wrong frame size (%dx%d)\n", __func__, width, height); in zoran_v4l_set_format()
180 zr->buffer_size = height * width * bpp; in zoran_v4l_set_format()
183 if (height * width * bpp > zr->buffer_size) { in zoran_v4l_set_format()
184 pci_dbg(zr->pci_dev, "%s - video buffer size (%d kB) is too small\n", in zoran_v4l_set_format()
185 __func__, zr->buffer_size >> 10); in zoran_v4l_set_format()
192 pci_dbg(zr->pci_dev, "%s - wrong frame alignment\n", __func__); in zoran_v4l_set_format()
196 zr->v4l_settings.width = width; in zoran_v4l_set_format()
197 zr->v4l_settings.height = height; in zoran_v4l_set_format()
198 zr->v4l_settings.format = format; in zoran_v4l_set_format()
199 zr->v4l_settings.bytesperline = bpp * zr->v4l_settings.width; in zoran_v4l_set_format()
204 static int zoran_set_norm(struct zoran *zr, v4l2_std_id norm) in zoran_set_norm() argument
206 if (!(norm & zr->card.norms)) { in zoran_set_norm()
207 pci_dbg(zr->pci_dev, "%s - unsupported norm %llx\n", __func__, norm); in zoran_set_norm()
212 zr->timing = zr->card.tvn[ZR_NORM_SECAM]; in zoran_set_norm()
214 zr->timing = zr->card.tvn[ZR_NORM_NTSC]; in zoran_set_norm()
216 zr->timing = zr->card.tvn[ZR_NORM_PAL]; in zoran_set_norm()
218 decoder_call(zr, video, s_std, norm); in zoran_set_norm()
219 encoder_call(zr, video, s_std_output, norm); in zoran_set_norm()
222 zr->norm = norm; in zoran_set_norm()
227 static int zoran_set_input(struct zoran *zr, int input) in zoran_set_input() argument
229 if (input == zr->input) in zoran_set_input()
232 if (input < 0 || input >= zr->card.inputs) { in zoran_set_input()
233 pci_dbg(zr->pci_dev, "%s - unsupported input %d\n", __func__, input); in zoran_set_input()
237 zr->input = input; in zoran_set_input()
239 decoder_call(zr, video, s_routing, zr->card.input[input].muxsel, 0, 0); in zoran_set_input()
250 struct zoran *zr = video_drvdata(file); in zoran_querycap() local
252 strscpy(cap->card, ZR_DEVNAME(zr), sizeof(cap->card)); in zoran_querycap()
254 snprintf(cap->bus_info, sizeof(cap->bus_info), "PCI:%s", pci_name(zr->pci_dev)); in zoran_querycap()
258 static int zoran_enum_fmt(struct zoran *zr, struct v4l2_fmtdesc *fmt, int flag) in zoran_enum_fmt() argument
284 struct zoran *zr = video_drvdata(file); in zoran_enum_fmt_vid_cap() local
286 return zoran_enum_fmt(zr, f, ZORAN_FORMAT_CAPTURE); in zoran_enum_fmt_vid_cap()
292 struct zoran *zr = video_drvdata(file); in zoran_g_fmt_vid_out() local
294 fmt->fmt.pix.width = zr->jpg_settings.img_width / zr->jpg_settings.hor_dcm; in zoran_g_fmt_vid_out()
295 fmt->fmt.pix.height = zr->jpg_settings.img_height * 2 / in zoran_g_fmt_vid_out()
296 (zr->jpg_settings.ver_dcm * zr->jpg_settings.tmp_dcm); in zoran_g_fmt_vid_out()
297 fmt->fmt.pix.sizeimage = zr->buffer_size; in zoran_g_fmt_vid_out()
299 if (zr->jpg_settings.tmp_dcm == 1) in zoran_g_fmt_vid_out()
300 fmt->fmt.pix.field = (zr->jpg_settings.odd_even ? in zoran_g_fmt_vid_out()
303 fmt->fmt.pix.field = (zr->jpg_settings.odd_even ? in zoran_g_fmt_vid_out()
314 struct zoran *zr = video_drvdata(file); in zoran_g_fmt_vid_cap() local
316 if (zr->map_mode != ZORAN_MAP_MODE_RAW) in zoran_g_fmt_vid_cap()
318 fmt->fmt.pix.width = zr->v4l_settings.width; in zoran_g_fmt_vid_cap()
319 fmt->fmt.pix.height = zr->v4l_settings.height; in zoran_g_fmt_vid_cap()
320 fmt->fmt.pix.sizeimage = zr->buffer_size; in zoran_g_fmt_vid_cap()
321 fmt->fmt.pix.pixelformat = zr->v4l_settings.format->fourcc; in zoran_g_fmt_vid_cap()
322 fmt->fmt.pix.colorspace = zr->v4l_settings.format->colorspace; in zoran_g_fmt_vid_cap()
323 fmt->fmt.pix.bytesperline = zr->v4l_settings.bytesperline; in zoran_g_fmt_vid_cap()
324 if (BUZ_MAX_HEIGHT < (zr->v4l_settings.height * 2)) in zoran_g_fmt_vid_cap()
334 struct zoran *zr = video_drvdata(file); in zoran_try_fmt_vid_out() local
341 settings = zr->jpg_settings; in zoran_try_fmt_vid_out()
349 if (fmt->fmt.pix.height <= zr->jpg_settings.img_height / 2) in zoran_try_fmt_vid_out()
353 if (fmt->fmt.pix.width <= zr->jpg_settings.img_width / 4) in zoran_try_fmt_vid_out()
355 else if (fmt->fmt.pix.width <= zr->jpg_settings.img_width / 2) in zoran_try_fmt_vid_out()
373 res = zoran_check_jpg_settings(zr, &settings, 1); in zoran_try_fmt_vid_out()
382 fmt->fmt.pix.field = (zr->jpg_settings.odd_even ? in zoran_try_fmt_vid_out()
385 fmt->fmt.pix.field = (zr->jpg_settings.odd_even ? in zoran_try_fmt_vid_out()
397 struct zoran *zr = video_drvdata(file); in zoran_try_fmt_vid_cap() local
433 struct zoran *zr = video_drvdata(file); in zoran_s_fmt_vid_out() local
438 pci_dbg(zr->pci_dev, "size=%dx%d, fmt=0x%x (%4.4s)\n", in zoran_s_fmt_vid_out()
448 settings = zr->jpg_settings; in zoran_s_fmt_vid_out()
456 if (fmt->fmt.pix.height <= zr->jpg_settings.img_height / 2) in zoran_s_fmt_vid_out()
460 if (fmt->fmt.pix.width <= zr->jpg_settings.img_width / 4) in zoran_s_fmt_vid_out()
462 else if (fmt->fmt.pix.width <= zr->jpg_settings.img_width / 2) in zoran_s_fmt_vid_out()
480 res = zoran_check_jpg_settings(zr, &settings, 0); in zoran_s_fmt_vid_out()
485 zr->jpg_settings = settings; in zoran_s_fmt_vid_out()
488 zr->map_mode = ZORAN_MAP_MODE_JPG_REC; in zoran_s_fmt_vid_out()
490 zr->map_mode = ZORAN_MAP_MODE_JPG_PLAY; in zoran_s_fmt_vid_out()
492 zr->buffer_size = zoran_v4l2_calc_bufsize(&zr->jpg_settings); in zoran_s_fmt_vid_out()
499 fmt->fmt.pix.field = (zr->jpg_settings.odd_even ? in zoran_s_fmt_vid_out()
502 fmt->fmt.pix.field = (zr->jpg_settings.odd_even ? in zoran_s_fmt_vid_out()
505 fmt->fmt.pix.sizeimage = zr->buffer_size; in zoran_s_fmt_vid_out()
513 struct zoran *zr = video_drvdata(file); in zoran_s_fmt_vid_cap() local
525 pci_dbg(zr->pci_dev, "VIDIOC_S_FMT - unknown/unsupported format 0x%x\n", in zoran_s_fmt_vid_cap()
541 zr->map_mode = ZORAN_MAP_MODE_RAW; in zoran_s_fmt_vid_cap()
543 res = zoran_v4l_set_format(zr, fmt->fmt.pix.width, fmt->fmt.pix.height, in zoran_s_fmt_vid_cap()
549 fmt->fmt.pix.bytesperline = zr->v4l_settings.bytesperline; in zoran_s_fmt_vid_cap()
550 fmt->fmt.pix.sizeimage = zr->buffer_size; in zoran_s_fmt_vid_cap()
551 fmt->fmt.pix.colorspace = zr->v4l_settings.format->colorspace; in zoran_s_fmt_vid_cap()
552 if (BUZ_MAX_HEIGHT < (zr->v4l_settings.height * 2)) in zoran_s_fmt_vid_cap()
561 struct zoran *zr = video_drvdata(file); in zoran_g_std() local
563 *std = zr->norm; in zoran_g_std()
569 struct zoran *zr = video_drvdata(file); in zoran_s_std() local
572 if (zr->norm == std) in zoran_s_std()
575 if (zr->running != ZORAN_MAP_MODE_NONE) in zoran_s_std()
578 res = zoran_set_norm(zr, std); in zoran_s_std()
585 struct zoran *zr = video_drvdata(file); in zoran_enum_input() local
587 if (inp->index >= zr->card.inputs) in zoran_enum_input()
590 strscpy(inp->name, zr->card.input[inp->index].name, sizeof(inp->name)); in zoran_enum_input()
595 decoder_call(zr, video, g_input_status, &inp->status); in zoran_enum_input()
601 struct zoran *zr = video_drvdata(file); in zoran_g_input() local
603 *input = zr->input; in zoran_g_input()
610 struct zoran *zr = video_drvdata(file); in zoran_s_input() local
613 if (zr->running != ZORAN_MAP_MODE_NONE) in zoran_s_input()
616 res = zoran_set_input(zr, input); in zoran_s_input()
623 struct zoran *zr = video_drvdata(file); in zoran_g_selection() local
627 pci_dbg(zr->pci_dev, "%s invalid selection type combination\n", __func__); in zoran_g_selection()
633 sel->r.top = zr->jpg_settings.img_y; in zoran_g_selection()
634 sel->r.left = zr->jpg_settings.img_x; in zoran_g_selection()
635 sel->r.width = zr->jpg_settings.img_width; in zoran_g_selection()
636 sel->r.height = zr->jpg_settings.img_height; in zoran_g_selection()
658 struct zoran *zr = video_drvdata(file); in zoran_s_selection() local
672 if (zr->map_mode == ZORAN_MAP_MODE_RAW) { in zoran_s_selection()
673 pci_dbg(zr->pci_dev, "VIDIOC_S_SELECTION - subcapture only supported for compressed capture\n"); in zoran_s_selection()
677 settings = zr->jpg_settings; in zoran_s_selection()
686 res = zoran_check_jpg_settings(zr, &settings, 0); in zoran_s_selection()
691 zr->jpg_settings = settings; in zoran_s_selection()
745 struct zoran *zr = vb2_get_drv_priv(vq); in zr_vb2_queue_setup() local
746 unsigned int size = zr->buffer_size; in zr_vb2_queue_setup()
748 pci_dbg(zr->pci_dev, "%s nbuf=%u nplanes=%u", __func__, *nbuffers, *nplanes); in zr_vb2_queue_setup()
750 zr->buf_in_reserve = 0; in zr_vb2_queue_setup()
770 struct zoran *zr = vb2_get_drv_priv(vb->vb2_queue); in zr_vb2_queue() local
774 spin_lock_irqsave(&zr->queued_bufs_lock, flags); in zr_vb2_queue()
775 list_add_tail(&buf->queue, &zr->queued_bufs); in zr_vb2_queue()
776 zr->buf_in_reserve++; in zr_vb2_queue()
777 spin_unlock_irqrestore(&zr->queued_bufs_lock, flags); in zr_vb2_queue()
778 if (zr->running == ZORAN_MAP_MODE_JPG_REC) in zr_vb2_queue()
779 zoran_feed_stat_com(zr); in zr_vb2_queue()
780 zr->queued++; in zr_vb2_queue()
785 struct zoran *zr = vb2_get_drv_priv(vb->vb2_queue); in zr_vb2_prepare() local
787 if (vb2_plane_size(vb, 0) < zr->buffer_size) in zr_vb2_prepare()
789 zr->prepared++; in zr_vb2_prepare()
794 int zr_set_buf(struct zoran *zr) in zr_set_buf() argument
802 if (zr->running == ZORAN_MAP_MODE_NONE) in zr_set_buf()
805 if (zr->inuse[0]) { in zr_set_buf()
806 buf = zr->inuse[0]; in zr_set_buf()
808 buf->vbuf.sequence = zr->vbseq++; in zr_set_buf()
812 if (BUZ_MAX_HEIGHT < (zr->v4l_settings.height * 2)) in zr_set_buf()
816 vb2_set_plane_payload(&buf->vbuf.vb2_buf, 0, zr->buffer_size); in zr_set_buf()
818 zr->inuse[0] = NULL; in zr_set_buf()
821 spin_lock_irqsave(&zr->queued_bufs_lock, flags); in zr_set_buf()
822 if (list_empty(&zr->queued_bufs)) { in zr_set_buf()
824 vb2_queue_error(zr->video_dev->queue); in zr_set_buf()
825 spin_unlock_irqrestore(&zr->queued_bufs_lock, flags); in zr_set_buf()
828 buf = list_first_entry_or_null(&zr->queued_bufs, struct zr_buffer, queue); in zr_set_buf()
831 vb2_queue_error(zr->video_dev->queue); in zr_set_buf()
832 spin_unlock_irqrestore(&zr->queued_bufs_lock, flags); in zr_set_buf()
836 zr->buf_in_reserve--; in zr_set_buf()
837 spin_unlock_irqrestore(&zr->queued_bufs_lock, flags); in zr_set_buf()
846 zr->inuse[0] = buf; in zr_set_buf()
850 if (zr->v4l_settings.height > BUZ_MAX_HEIGHT / 2) in zr_set_buf()
851 reg += zr->v4l_settings.bytesperline; in zr_set_buf()
855 if (zr->v4l_settings.height > BUZ_MAX_HEIGHT / 2) in zr_set_buf()
856 reg += zr->v4l_settings.bytesperline; in zr_set_buf()
869 struct zoran *zr = vq->drv_priv; in zr_vb2_start_streaming() local
873 zr->stat_com[j] = cpu_to_le32(1); in zr_vb2_start_streaming()
874 zr->inuse[j] = NULL; in zr_vb2_start_streaming()
876 zr->vbseq = 0; in zr_vb2_start_streaming()
878 if (zr->map_mode != ZORAN_MAP_MODE_RAW) { in zr_vb2_start_streaming()
879 pci_dbg(zr->pci_dev, "START JPG\n"); in zr_vb2_start_streaming()
880 zr36057_restart(zr); in zr_vb2_start_streaming()
881 zoran_init_hardware(zr); in zr_vb2_start_streaming()
882 if (zr->map_mode == ZORAN_MAP_MODE_JPG_REC) in zr_vb2_start_streaming()
883 zr36057_enable_jpg(zr, BUZ_MODE_MOTION_DECOMPRESS); in zr_vb2_start_streaming()
885 zr36057_enable_jpg(zr, BUZ_MODE_MOTION_COMPRESS); in zr_vb2_start_streaming()
886 zoran_feed_stat_com(zr); in zr_vb2_start_streaming()
887 jpeg_start(zr); in zr_vb2_start_streaming()
888 zr->running = zr->map_mode; in zr_vb2_start_streaming()
893 pci_dbg(zr->pci_dev, "START RAW\n"); in zr_vb2_start_streaming()
894 zr36057_restart(zr); in zr_vb2_start_streaming()
895 zoran_init_hardware(zr); in zr_vb2_start_streaming()
897 zr36057_enable_jpg(zr, BUZ_MODE_IDLE); in zr_vb2_start_streaming()
898 zr36057_set_memgrab(zr, 1); in zr_vb2_start_streaming()
899 zr->running = zr->map_mode; in zr_vb2_start_streaming()
906 struct zoran *zr = vq->drv_priv; in zr_vb2_stop_streaming() local
912 if (zr->map_mode != ZORAN_MAP_MODE_RAW) in zr_vb2_stop_streaming()
913 zr36057_enable_jpg(zr, BUZ_MODE_IDLE); in zr_vb2_stop_streaming()
914 zr36057_set_memgrab(zr, 0); in zr_vb2_stop_streaming()
915 zr->running = ZORAN_MAP_MODE_NONE; in zr_vb2_stop_streaming()
917 zoran_set_pci_master(zr, 0); in zr_vb2_stop_streaming()
920 decoder_call(zr, video, s_stream, 0); in zr_vb2_stop_streaming()
921 encoder_call(zr, video, s_routing, 2, 0, 0); in zr_vb2_stop_streaming()
925 zr->stat_com[j] = cpu_to_le32(1); in zr_vb2_stop_streaming()
926 if (!zr->inuse[j]) in zr_vb2_stop_streaming()
928 buf = zr->inuse[j]; in zr_vb2_stop_streaming()
929 pci_dbg(zr->pci_dev, "%s clean buf %d\n", __func__, j); in zr_vb2_stop_streaming()
931 zr->inuse[j] = NULL; in zr_vb2_stop_streaming()
934 spin_lock_irqsave(&zr->queued_bufs_lock, flags); in zr_vb2_stop_streaming()
935 while (!list_empty(&zr->queued_bufs)) { in zr_vb2_stop_streaming()
936 buf = list_entry(zr->queued_bufs.next, struct zr_buffer, queue); in zr_vb2_stop_streaming()
939 zr->buf_in_reserve--; in zr_vb2_stop_streaming()
941 spin_unlock_irqrestore(&zr->queued_bufs_lock, flags); in zr_vb2_stop_streaming()
942 if (zr->buf_in_reserve) in zr_vb2_stop_streaming()
943 pci_dbg(zr->pci_dev, "Buffer remaining %d\n", zr->buf_in_reserve); in zr_vb2_stop_streaming()
944 zr->map_mode = ZORAN_MAP_MODE_RAW; in zr_vb2_stop_streaming()
957 int zoran_queue_init(struct zoran *zr, struct vb2_queue *vq, int dir) in zoran_queue_init() argument
961 spin_lock_init(&zr->queued_bufs_lock); in zoran_queue_init()
962 INIT_LIST_HEAD(&zr->queued_bufs); in zoran_queue_init()
964 vq->dev = &zr->pci_dev->dev; in zoran_queue_init()
968 vq->drv_priv = zr; in zoran_queue_init()
975 vq->lock = &zr->lock; in zoran_queue_init()
979 zr->video_dev->queue = vq; in zoran_queue_init()
983 void zoran_queue_exit(struct zoran *zr) in zoran_queue_exit() argument
985 vb2_queue_release(zr->video_dev->queue); in zoran_queue_exit()