Lines Matching refs:vou_dev

86 static void sh_vou_reg_a_write(struct sh_vou_device *vou_dev, unsigned int reg,  in sh_vou_reg_a_write()  argument
89 __raw_writel(value, vou_dev->base + reg); in sh_vou_reg_a_write()
92 static void sh_vou_reg_ab_write(struct sh_vou_device *vou_dev, unsigned int reg, in sh_vou_reg_ab_write() argument
95 __raw_writel(value, vou_dev->base + reg); in sh_vou_reg_ab_write()
96 __raw_writel(value, vou_dev->base + reg + 0x1000); in sh_vou_reg_ab_write()
99 static void sh_vou_reg_m_write(struct sh_vou_device *vou_dev, unsigned int reg, in sh_vou_reg_m_write() argument
102 __raw_writel(value, vou_dev->base + reg + 0x2000); in sh_vou_reg_m_write()
105 static u32 sh_vou_reg_a_read(struct sh_vou_device *vou_dev, unsigned int reg) in sh_vou_reg_a_read() argument
107 return __raw_readl(vou_dev->base + reg); in sh_vou_reg_a_read()
110 static void sh_vou_reg_a_set(struct sh_vou_device *vou_dev, unsigned int reg, in sh_vou_reg_a_set() argument
113 u32 old = __raw_readl(vou_dev->base + reg); in sh_vou_reg_a_set()
116 __raw_writel(value, vou_dev->base + reg); in sh_vou_reg_a_set()
119 static void sh_vou_reg_b_set(struct sh_vou_device *vou_dev, unsigned int reg, in sh_vou_reg_b_set() argument
122 sh_vou_reg_a_set(vou_dev, reg + 0x1000, value, mask); in sh_vou_reg_b_set()
125 static void sh_vou_reg_ab_set(struct sh_vou_device *vou_dev, unsigned int reg, in sh_vou_reg_ab_set() argument
128 sh_vou_reg_a_set(vou_dev, reg, value, mask); in sh_vou_reg_ab_set()
129 sh_vou_reg_b_set(vou_dev, reg, value, mask); in sh_vou_reg_ab_set()
180 static void sh_vou_schedule_next(struct sh_vou_device *vou_dev, in sh_vou_schedule_next() argument
186 switch (vou_dev->pix.pixelformat) { in sh_vou_schedule_next()
189 addr2 = addr1 + vou_dev->pix.width * vou_dev->pix.height; in sh_vou_schedule_next()
195 sh_vou_reg_m_write(vou_dev, VOUAD1R, addr1); in sh_vou_schedule_next()
196 sh_vou_reg_m_write(vou_dev, VOUAD2R, addr2); in sh_vou_schedule_next()
199 static void sh_vou_stream_start(struct sh_vou_device *vou_dev, in sh_vou_stream_start() argument
209 switch (vou_dev->pix.pixelformat) { in sh_vou_stream_start()
225 sh_vou_reg_a_write(vou_dev, VOUSWR, dataswap); in sh_vou_stream_start()
226 sh_vou_reg_ab_write(vou_dev, VOUAIR, vou_dev->pix.width * row_coeff); in sh_vou_stream_start()
227 sh_vou_schedule_next(vou_dev, vb); in sh_vou_stream_start()
245 struct sh_vou_device *vou_dev = video_get_drvdata(vdev); in sh_vou_buf_setup() local
247 *size = vou_fmt[vou_dev->pix_idx].bpp * vou_dev->pix.width * in sh_vou_buf_setup()
248 vou_dev->pix.height / 8; in sh_vou_buf_setup()
257 dev_dbg(vou_dev->v4l2_dev.dev, "%s(): count=%d, size=%d\n", __func__, in sh_vou_buf_setup()
269 struct sh_vou_device *vou_dev = video_get_drvdata(vdev); in sh_vou_buf_prepare() local
270 struct v4l2_pix_format *pix = &vou_dev->pix; in sh_vou_buf_prepare()
271 int bytes_per_line = vou_fmt[vou_dev->pix_idx].bpp * pix->width / 8; in sh_vou_buf_prepare()
274 dev_dbg(vou_dev->v4l2_dev.dev, "%s()\n", __func__); in sh_vou_buf_prepare()
304 dev_dbg(vou_dev->v4l2_dev.dev, in sh_vou_buf_prepare()
306 __func__, vou_dev->pix_idx, bytes_per_line, in sh_vou_buf_prepare()
318 struct sh_vou_device *vou_dev = video_get_drvdata(vdev); in sh_vou_buf_queue() local
320 dev_dbg(vou_dev->v4l2_dev.dev, "%s()\n", __func__); in sh_vou_buf_queue()
323 list_add_tail(&vb->queue, &vou_dev->queue); in sh_vou_buf_queue()
325 if (vou_dev->status == SH_VOU_RUNNING) { in sh_vou_buf_queue()
327 } else if (!vou_dev->active) { in sh_vou_buf_queue()
328 vou_dev->active = vb; in sh_vou_buf_queue()
330 sh_vou_reg_a_write(vou_dev, VOURPR, 1); in sh_vou_buf_queue()
331 dev_dbg(vou_dev->v4l2_dev.dev, "%s: first buffer status 0x%x\n", in sh_vou_buf_queue()
332 __func__, sh_vou_reg_a_read(vou_dev, VOUSTR)); in sh_vou_buf_queue()
333 sh_vou_schedule_next(vou_dev, vb); in sh_vou_buf_queue()
335 } else if (vou_dev->active->queue.next == &vb->queue) { in sh_vou_buf_queue()
337 sh_vou_reg_a_write(vou_dev, VOURPR, 0); in sh_vou_buf_queue()
338 sh_vou_stream_start(vou_dev, vb); in sh_vou_buf_queue()
341 sh_vou_reg_a_write(vou_dev, VOURCR, 5); in sh_vou_buf_queue()
342 dev_dbg(vou_dev->v4l2_dev.dev, "%s: second buffer status 0x%x\n", in sh_vou_buf_queue()
343 __func__, sh_vou_reg_a_read(vou_dev, VOUSTR)); in sh_vou_buf_queue()
346 sh_vou_reg_a_write(vou_dev, VOUIR, 0x10004); in sh_vou_buf_queue()
349 vou_dev->status = SH_VOU_RUNNING; in sh_vou_buf_queue()
350 sh_vou_reg_a_write(vou_dev, VOUER, 0x107); in sh_vou_buf_queue()
358 struct sh_vou_device *vou_dev = video_get_drvdata(vdev); in sh_vou_buf_release() local
361 dev_dbg(vou_dev->v4l2_dev.dev, "%s()\n", __func__); in sh_vou_buf_release()
363 spin_lock_irqsave(&vou_dev->lock, flags); in sh_vou_buf_release()
365 if (vou_dev->active == vb) { in sh_vou_buf_release()
367 sh_vou_reg_a_set(vou_dev, VOUER, 0, 1); in sh_vou_buf_release()
369 sh_vou_reg_a_set(vou_dev, VOUIR, 0, 0x30000); in sh_vou_buf_release()
370 vou_dev->active = NULL; in sh_vou_buf_release()
378 spin_unlock_irqrestore(&vou_dev->lock, flags); in sh_vou_buf_release()
394 struct sh_vou_device *vou_dev = video_drvdata(file); in sh_vou_querycap() local
396 dev_dbg(vou_dev->v4l2_dev.dev, "%s()\n", __func__); in sh_vou_querycap()
408 struct sh_vou_device *vou_dev = video_drvdata(file); in sh_vou_enum_fmt_vid_out() local
413 dev_dbg(vou_dev->v4l2_dev.dev, "%s()\n", __func__); in sh_vou_enum_fmt_vid_out()
426 struct sh_vou_device *vou_dev = video_drvdata(file); in sh_vou_g_fmt_vid_out() local
428 dev_dbg(vou_dev->v4l2_dev.dev, "%s()\n", __func__); in sh_vou_g_fmt_vid_out()
431 fmt->fmt.pix = vou_dev->pix; in sh_vou_g_fmt_vid_out()
443 static void sh_vou_configure_geometry(struct sh_vou_device *vou_dev, in sh_vou_configure_geometry() argument
449 struct v4l2_rect *rect = &vou_dev->rect; in sh_vou_configure_geometry()
450 struct v4l2_pix_format *pix = &vou_dev->pix; in sh_vou_configure_geometry()
453 if (vou_dev->std & V4L2_STD_525_60) { in sh_vou_configure_geometry()
490 dev_dbg(vou_dev->v4l2_dev.dev, in sh_vou_configure_geometry()
496 sh_vou_reg_ab_write(vou_dev, VOUISR, (pix->width << 16) | frame_in_height); in sh_vou_configure_geometry()
497 sh_vou_reg_ab_write(vou_dev, VOUVPR, (black_left << 16) | black_top); in sh_vou_configure_geometry()
498 sh_vou_reg_ab_write(vou_dev, VOUDPR, (rect->left << 16) | frame_out_top); in sh_vou_configure_geometry()
499 sh_vou_reg_ab_write(vou_dev, VOUDSR, (dsr_h << 16) | dsr_v); in sh_vou_configure_geometry()
511 dev_dbg(vou_dev->v4l2_dev.dev, "%s: scaling 0x%x\n", fmt->desc, vouvcr); in sh_vou_configure_geometry()
514 sh_vou_reg_ab_write(vou_dev, VOUVCR, vouvcr); in sh_vou_configure_geometry()
515 sh_vou_reg_ab_write(vou_dev, VOUDFR, in sh_vou_configure_geometry()
677 struct sh_vou_device *vou_dev = video_drvdata(file); in sh_vou_s_fmt_vid_out() local
690 dev_dbg(vou_dev->v4l2_dev.dev, "%s(): %ux%u -> %ux%u\n", __func__, in sh_vou_s_fmt_vid_out()
691 vou_dev->rect.width, vou_dev->rect.height, in sh_vou_s_fmt_vid_out()
708 if (vou_dev->std & V4L2_STD_525_60) in sh_vou_s_fmt_vid_out()
719 geo.output = vou_dev->rect; in sh_vou_s_fmt_vid_out()
721 vou_adjust_output(&geo, vou_dev->std); in sh_vou_s_fmt_vid_out()
725 ret = v4l2_device_call_until_err(&vou_dev->v4l2_dev, 0, video, in sh_vou_s_fmt_vid_out()
731 dev_dbg(vou_dev->v4l2_dev.dev, "%s(): %ux%u -> %ux%u\n", __func__, in sh_vou_s_fmt_vid_out()
745 vou_adjust_input(&geo, vou_dev->std); in sh_vou_s_fmt_vid_out()
749 vou_dev->rect = geo.output; in sh_vou_s_fmt_vid_out()
753 dev_dbg(vou_dev->v4l2_dev.dev, "%s(): %ux%u\n", __func__, in sh_vou_s_fmt_vid_out()
756 vou_dev->pix_idx = pix_idx; in sh_vou_s_fmt_vid_out()
758 vou_dev->pix = *pix; in sh_vou_s_fmt_vid_out()
760 sh_vou_configure_geometry(vou_dev, pix_idx, in sh_vou_s_fmt_vid_out()
769 struct sh_vou_device *vou_dev = video_drvdata(file); in sh_vou_try_fmt_vid_out() local
773 dev_dbg(vou_dev->v4l2_dev.dev, "%s()\n", __func__); in sh_vou_try_fmt_vid_out()
793 struct sh_vou_device *vou_dev = video_drvdata(file); in sh_vou_reqbufs() local
796 dev_dbg(vou_dev->v4l2_dev.dev, "%s()\n", __func__); in sh_vou_reqbufs()
807 struct sh_vou_device *vou_dev = video_drvdata(file); in sh_vou_querybuf() local
810 dev_dbg(vou_dev->v4l2_dev.dev, "%s()\n", __func__); in sh_vou_querybuf()
817 struct sh_vou_device *vou_dev = video_drvdata(file); in sh_vou_qbuf() local
820 dev_dbg(vou_dev->v4l2_dev.dev, "%s()\n", __func__); in sh_vou_qbuf()
827 struct sh_vou_device *vou_dev = video_drvdata(file); in sh_vou_dqbuf() local
830 dev_dbg(vou_dev->v4l2_dev.dev, "%s()\n", __func__); in sh_vou_dqbuf()
838 struct sh_vou_device *vou_dev = video_drvdata(file); in sh_vou_streamon() local
842 dev_dbg(vou_dev->v4l2_dev.dev, "%s()\n", __func__); in sh_vou_streamon()
844 ret = v4l2_device_call_until_err(&vou_dev->v4l2_dev, 0, in sh_vou_streamon()
856 struct sh_vou_device *vou_dev = video_drvdata(file); in sh_vou_streamoff() local
859 dev_dbg(vou_dev->v4l2_dev.dev, "%s()\n", __func__); in sh_vou_streamoff()
866 v4l2_device_call_until_err(&vou_dev->v4l2_dev, 0, video, s_stream, 0); in sh_vou_streamoff()
888 struct sh_vou_device *vou_dev = video_drvdata(file); in sh_vou_s_std() local
891 dev_dbg(vou_dev->v4l2_dev.dev, "%s(): 0x%llx\n", __func__, std_id); in sh_vou_s_std()
893 if (std_id & ~vou_dev->vdev.tvnorms) in sh_vou_s_std()
896 ret = v4l2_device_call_until_err(&vou_dev->v4l2_dev, 0, video, in sh_vou_s_std()
903 sh_vou_reg_ab_set(vou_dev, VOUCR, in sh_vou_s_std()
904 sh_vou_ntsc_mode(vou_dev->pdata->bus_fmt) << 29, 7 << 29); in sh_vou_s_std()
906 sh_vou_reg_ab_set(vou_dev, VOUCR, 5 << 29, 7 << 29); in sh_vou_s_std()
908 vou_dev->std = std_id; in sh_vou_s_std()
915 struct sh_vou_device *vou_dev = video_drvdata(file); in sh_vou_g_std() local
917 dev_dbg(vou_dev->v4l2_dev.dev, "%s()\n", __func__); in sh_vou_g_std()
919 *std = vou_dev->std; in sh_vou_g_std()
926 struct sh_vou_device *vou_dev = video_drvdata(file); in sh_vou_g_crop() local
928 dev_dbg(vou_dev->v4l2_dev.dev, "%s()\n", __func__); in sh_vou_g_crop()
931 a->c = vou_dev->rect; in sh_vou_g_crop()
940 struct sh_vou_device *vou_dev = video_drvdata(file); in sh_vou_s_crop() local
943 struct v4l2_pix_format *pix = &vou_dev->pix; in sh_vou_s_crop()
954 dev_dbg(vou_dev->v4l2_dev.dev, "%s(): %ux%u@%u:%u\n", __func__, in sh_vou_s_crop()
960 if (vou_dev->std & V4L2_STD_525_60) in sh_vou_s_crop()
985 v4l2_device_call_until_err(&vou_dev->v4l2_dev, 0, video, in sh_vou_s_crop()
989 ret = v4l2_device_call_until_err(&vou_dev->v4l2_dev, 0, video, in sh_vou_s_crop()
1008 vou_adjust_input(&geo, vou_dev->std); in sh_vou_s_crop()
1011 vou_dev->rect = geo.output; in sh_vou_s_crop()
1015 sh_vou_configure_geometry(vou_dev, vou_dev->pix_idx, in sh_vou_s_crop()
1031 struct sh_vou_device *vou_dev = video_drvdata(file); in sh_vou_cropcap() local
1033 dev_dbg(vou_dev->v4l2_dev.dev, "%s()\n", __func__); in sh_vou_cropcap()
1053 struct sh_vou_device *vou_dev = dev_id; in sh_vou_isr() local
1057 u32 irq_status = sh_vou_reg_a_read(vou_dev, VOUIR), masked; in sh_vou_isr()
1058 u32 vou_status = sh_vou_reg_a_read(vou_dev, VOUSTR); in sh_vou_isr()
1062 dev_warn(vou_dev->v4l2_dev.dev, "IRQ status 0x%x!\n", in sh_vou_isr()
1067 spin_lock(&vou_dev->lock); in sh_vou_isr()
1068 if (!vou_dev->active || list_empty(&vou_dev->queue)) { in sh_vou_isr()
1070 dev_warn(vou_dev->v4l2_dev.dev, in sh_vou_isr()
1073 sh_vou_reg_a_set(vou_dev, VOUIR, 0, 0x300); in sh_vou_isr()
1074 spin_unlock(&vou_dev->lock); in sh_vou_isr()
1079 dev_dbg(vou_dev->v4l2_dev.dev, in sh_vou_isr()
1087 sh_vou_reg_a_write(vou_dev, VOUIR, masked); in sh_vou_isr()
1089 vb = vou_dev->active; in sh_vou_isr()
1097 if (list_empty(&vou_dev->queue)) { in sh_vou_isr()
1099 dev_dbg(vou_dev->v4l2_dev.dev, "%s: queue empty after %d\n", in sh_vou_isr()
1101 sh_vou_reg_a_set(vou_dev, VOUER, 0, 1); in sh_vou_isr()
1102 vou_dev->active = NULL; in sh_vou_isr()
1103 vou_dev->status = SH_VOU_INITIALISING; in sh_vou_isr()
1105 sh_vou_reg_a_set(vou_dev, VOUIR, 0, 0x30000); in sh_vou_isr()
1106 spin_unlock(&vou_dev->lock); in sh_vou_isr()
1110 vou_dev->active = list_entry(vou_dev->queue.next, in sh_vou_isr()
1113 if (vou_dev->active->queue.next != &vou_dev->queue) { in sh_vou_isr()
1114 struct videobuf_buffer *new = list_entry(vou_dev->active->queue.next, in sh_vou_isr()
1116 sh_vou_schedule_next(vou_dev, new); in sh_vou_isr()
1119 spin_unlock(&vou_dev->lock); in sh_vou_isr()
1124 static int sh_vou_hw_init(struct sh_vou_device *vou_dev) in sh_vou_hw_init() argument
1126 struct sh_vou_pdata *pdata = vou_dev->pdata; in sh_vou_hw_init()
1131 sh_vou_reg_a_write(vou_dev, VOUIR, 0); in sh_vou_hw_init()
1134 sh_vou_reg_a_write(vou_dev, VOUSRR, 0x101); in sh_vou_hw_init()
1135 while (--i && (sh_vou_reg_a_read(vou_dev, VOUSRR) & 0x101)) in sh_vou_hw_init()
1141 dev_dbg(vou_dev->v4l2_dev.dev, "Reset took %dus\n", 100 - i); in sh_vou_hw_init()
1149 sh_vou_reg_ab_set(vou_dev, VOUCR, voucr, 0xfc000000); in sh_vou_hw_init()
1152 sh_vou_reg_a_write(vou_dev, VOURCR, 4); in sh_vou_hw_init()
1154 sh_vou_reg_ab_write(vou_dev, VOUMSR, 0x800000); in sh_vou_hw_init()
1162 struct sh_vou_device *vou_dev = video_drvdata(file); in sh_vou_open() local
1169 dev_dbg(vou_dev->v4l2_dev.dev, "%s()\n", __func__); in sh_vou_open()
1171 if (mutex_lock_interruptible(&vou_dev->fop_lock)) { in sh_vou_open()
1175 if (atomic_inc_return(&vou_dev->use_count) == 1) { in sh_vou_open()
1178 vou_dev->status = SH_VOU_INITIALISING; in sh_vou_open()
1179 pm_runtime_get_sync(vou_dev->v4l2_dev.dev); in sh_vou_open()
1180 ret = sh_vou_hw_init(vou_dev); in sh_vou_open()
1182 atomic_dec(&vou_dev->use_count); in sh_vou_open()
1183 pm_runtime_put(vou_dev->v4l2_dev.dev); in sh_vou_open()
1184 vou_dev->status = SH_VOU_IDLE; in sh_vou_open()
1185 mutex_unlock(&vou_dev->fop_lock); in sh_vou_open()
1192 vou_dev->v4l2_dev.dev, &vou_dev->lock, in sh_vou_open()
1196 &vou_dev->vdev, &vou_dev->fop_lock); in sh_vou_open()
1197 mutex_unlock(&vou_dev->fop_lock); in sh_vou_open()
1206 struct sh_vou_device *vou_dev = video_drvdata(file); in sh_vou_release() local
1209 dev_dbg(vou_dev->v4l2_dev.dev, "%s()\n", __func__); in sh_vou_release()
1211 if (!atomic_dec_return(&vou_dev->use_count)) { in sh_vou_release()
1212 mutex_lock(&vou_dev->fop_lock); in sh_vou_release()
1214 vou_dev->status = SH_VOU_IDLE; in sh_vou_release()
1215 sh_vou_reg_a_set(vou_dev, VOUER, 0, 0x101); in sh_vou_release()
1216 pm_runtime_put(vou_dev->v4l2_dev.dev); in sh_vou_release()
1217 mutex_unlock(&vou_dev->fop_lock); in sh_vou_release()
1228 struct sh_vou_device *vou_dev = video_drvdata(file); in sh_vou_mmap() local
1232 dev_dbg(vou_dev->v4l2_dev.dev, "%s()\n", __func__); in sh_vou_mmap()
1234 if (mutex_lock_interruptible(&vou_dev->fop_lock)) in sh_vou_mmap()
1237 mutex_unlock(&vou_dev->fop_lock); in sh_vou_mmap()
1243 struct sh_vou_device *vou_dev = video_drvdata(file); in sh_vou_poll() local
1247 dev_dbg(vou_dev->v4l2_dev.dev, "%s()\n", __func__); in sh_vou_poll()
1249 mutex_lock(&vou_dev->fop_lock); in sh_vou_poll()
1251 mutex_unlock(&vou_dev->fop_lock); in sh_vou_poll()
1299 struct sh_vou_device *vou_dev; in sh_vou_probe() local
1312 vou_dev = kzalloc(sizeof(*vou_dev), GFP_KERNEL); in sh_vou_probe()
1313 if (!vou_dev) in sh_vou_probe()
1316 INIT_LIST_HEAD(&vou_dev->queue); in sh_vou_probe()
1317 spin_lock_init(&vou_dev->lock); in sh_vou_probe()
1318 mutex_init(&vou_dev->fop_lock); in sh_vou_probe()
1319 atomic_set(&vou_dev->use_count, 0); in sh_vou_probe()
1320 vou_dev->pdata = vou_pdata; in sh_vou_probe()
1321 vou_dev->status = SH_VOU_IDLE; in sh_vou_probe()
1323 rect = &vou_dev->rect; in sh_vou_probe()
1324 pix = &vou_dev->pix; in sh_vou_probe()
1327 vou_dev->std = V4L2_STD_NTSC_M; in sh_vou_probe()
1348 vou_dev->base = ioremap(reg_res->start, resource_size(reg_res)); in sh_vou_probe()
1349 if (!vou_dev->base) { in sh_vou_probe()
1354 ret = request_irq(irq, sh_vou_isr, 0, "vou", vou_dev); in sh_vou_probe()
1358 ret = v4l2_device_register(&pdev->dev, &vou_dev->v4l2_dev); in sh_vou_probe()
1364 vdev = &vou_dev->vdev; in sh_vou_probe()
1368 vdev->v4l2_dev = &vou_dev->v4l2_dev; in sh_vou_probe()
1370 vdev->lock = &vou_dev->fop_lock; in sh_vou_probe()
1372 video_set_drvdata(vdev, vou_dev); in sh_vou_probe()
1383 ret = sh_vou_hw_init(vou_dev); in sh_vou_probe()
1387 subdev = v4l2_i2c_new_subdev_board(&vou_dev->v4l2_dev, i2c_adap, in sh_vou_probe()
1406 v4l2_device_unregister(&vou_dev->v4l2_dev); in sh_vou_probe()
1408 free_irq(irq, vou_dev); in sh_vou_probe()
1410 iounmap(vou_dev->base); in sh_vou_probe()
1414 kfree(vou_dev); in sh_vou_probe()
1422 struct sh_vou_device *vou_dev = container_of(v4l2_dev, in sh_vou_remove() local
1430 free_irq(irq, vou_dev); in sh_vou_remove()
1432 video_unregister_device(&vou_dev->vdev); in sh_vou_remove()
1434 v4l2_device_unregister(&vou_dev->v4l2_dev); in sh_vou_remove()
1435 iounmap(vou_dev->base); in sh_vou_remove()
1439 kfree(vou_dev); in sh_vou_remove()