1 // SPDX-License-Identifier: GPL-2.0-only
3 * Copyright (C) 2010 Texas Instruments Incorporated - https://www.ti.com/
5 #include <linux/kernel.h>
6 #include <linux/init.h>
7 #include <linux/module.h>
8 #include <linux/errno.h>
9 #include <linux/interrupt.h>
10 #include <linux/string.h>
11 #include <linux/wait.h>
12 #include <linux/time.h>
13 #include <linux/platform_device.h>
14 #include <linux/irq.h>
16 #include <linux/mutex.h>
17 #include <linux/videodev2.h>
18 #include <linux/slab.h>
21 #include <media/v4l2-dev.h>
22 #include <media/v4l2-common.h>
23 #include <media/v4l2-ioctl.h>
24 #include <media/v4l2-device.h>
25 #include <media/davinci/vpbe_display.h>
26 #include <media/davinci/vpbe_types.h>
27 #include <media/davinci/vpbe.h>
28 #include <media/davinci/vpbe_venc.h>
29 #include <media/davinci/vpbe_osd.h>
30 #include "vpbe_venc_regs.h"
32 #define VPBE_DISPLAY_DRIVER "vpbe-v4l2"
36 #define VPBE_DEFAULT_NUM_BUFS 3
38 module_param(debug, int, 0644);
40 static int vpbe_set_osd_display_params(struct vpbe_display *disp_dev,
41 struct vpbe_layer *layer);
43 static int venc_is_second_field(struct vpbe_display *disp_dev)
45 struct vpbe_device *vpbe_dev = disp_dev->vpbe_dev;
48 ret = v4l2_subdev_call(vpbe_dev->venc,
54 v4l2_err(&vpbe_dev->v4l2_dev,
55 "Error in getting Field ID 0\n");
61 static void vpbe_isr_even_field(struct vpbe_display *disp_obj,
62 struct vpbe_layer *layer)
64 if (layer->cur_frm == layer->next_frm)
67 layer->cur_frm->vb.vb2_buf.timestamp = ktime_get_ns();
68 vb2_buffer_done(&layer->cur_frm->vb.vb2_buf, VB2_BUF_STATE_DONE);
69 /* Make cur_frm pointing to next_frm */
70 layer->cur_frm = layer->next_frm;
73 static void vpbe_isr_odd_field(struct vpbe_display *disp_obj,
74 struct vpbe_layer *layer)
76 struct osd_state *osd_device = disp_obj->osd_device;
79 spin_lock(&disp_obj->dma_queue_lock);
80 if (list_empty(&layer->dma_queue) ||
81 (layer->cur_frm != layer->next_frm)) {
82 spin_unlock(&disp_obj->dma_queue_lock);
86 * one field is displayed configure
87 * the next frame if it is available
88 * otherwise hold on current frame
89 * Get next from the buffer queue
91 layer->next_frm = list_entry(layer->dma_queue.next,
92 struct vpbe_disp_buffer, list);
93 /* Remove that from the buffer queue */
94 list_del(&layer->next_frm->list);
95 spin_unlock(&disp_obj->dma_queue_lock);
96 /* Mark state of the frame to active */
97 layer->next_frm->vb.vb2_buf.state = VB2_BUF_STATE_ACTIVE;
98 addr = vb2_dma_contig_plane_dma_addr(&layer->next_frm->vb.vb2_buf, 0);
99 osd_device->ops.start_layer(osd_device,
100 layer->layer_info.id,
102 disp_obj->cbcr_ofst);
105 /* interrupt service routine */
106 static irqreturn_t venc_isr(int irq, void *arg)
108 struct vpbe_display *disp_dev = (struct vpbe_display *)arg;
109 struct vpbe_layer *layer;
110 static unsigned last_event;
115 if (!arg || !disp_dev->dev[0])
118 if (venc_is_second_field(disp_dev))
119 event |= VENC_SECOND_FIELD;
121 event |= VENC_FIRST_FIELD;
123 if (event == (last_event & ~VENC_END_OF_FRAME)) {
125 * If the display is non-interlaced, then we need to flag the
126 * end-of-frame event at every interrupt regardless of the
127 * value of the FIDST bit. We can conclude that the display is
128 * non-interlaced if the value of the FIDST bit is unchanged
129 * from the previous interrupt.
131 event |= VENC_END_OF_FRAME;
132 } else if (event == VENC_SECOND_FIELD) {
133 /* end-of-frame for interlaced display */
134 event |= VENC_END_OF_FRAME;
138 for (i = 0; i < VPBE_DISPLAY_MAX_DEVICES; i++) {
139 layer = disp_dev->dev[i];
141 if (!vb2_start_streaming_called(&layer->buffer_queue))
144 if (layer->layer_first_int) {
145 layer->layer_first_int = 0;
148 /* Check the field format */
149 if ((V4L2_FIELD_NONE == layer->pix_fmt.field) &&
150 (event & VENC_END_OF_FRAME)) {
151 /* Progressive mode */
153 vpbe_isr_even_field(disp_dev, layer);
154 vpbe_isr_odd_field(disp_dev, layer);
156 /* Interlaced mode */
158 layer->field_id ^= 1;
159 if (event & VENC_FIRST_FIELD)
165 * If field id does not match with store
168 if (fid != layer->field_id) {
169 /* Make them in sync */
170 layer->field_id = fid;
174 * device field id and local field id are
175 * in sync. If this is even field
178 vpbe_isr_even_field(disp_dev, layer);
180 vpbe_isr_odd_field(disp_dev, layer);
188 * vpbe_buffer_prepare()
189 * This is the callback function called from vb2_qbuf() function
190 * the buffer is prepared and user space virtual address is converted into
193 static int vpbe_buffer_prepare(struct vb2_buffer *vb)
195 struct vb2_queue *q = vb->vb2_queue;
196 struct vpbe_layer *layer = vb2_get_drv_priv(q);
197 struct vpbe_device *vpbe_dev = layer->disp_dev->vpbe_dev;
200 v4l2_dbg(1, debug, &vpbe_dev->v4l2_dev,
201 "vpbe_buffer_prepare\n");
203 vb2_set_plane_payload(vb, 0, layer->pix_fmt.sizeimage);
204 if (vb2_get_plane_payload(vb, 0) > vb2_plane_size(vb, 0))
207 addr = vb2_dma_contig_plane_dma_addr(vb, 0);
208 if (!IS_ALIGNED(addr, 8)) {
209 v4l2_err(&vpbe_dev->v4l2_dev,
210 "buffer_prepare:offset is not aligned to 32 bytes\n");
217 * vpbe_buffer_setup()
218 * This function allocates memory for the buffers
221 vpbe_buffer_queue_setup(struct vb2_queue *vq,
222 unsigned int *nbuffers, unsigned int *nplanes,
223 unsigned int sizes[], struct device *alloc_devs[])
226 /* Get the file handle object and layer object */
227 struct vpbe_layer *layer = vb2_get_drv_priv(vq);
228 struct vpbe_device *vpbe_dev = layer->disp_dev->vpbe_dev;
230 v4l2_dbg(1, debug, &vpbe_dev->v4l2_dev, "vpbe_buffer_setup\n");
232 /* Store number of buffers allocated in numbuffer member */
233 if (vq->num_buffers + *nbuffers < VPBE_DEFAULT_NUM_BUFS)
234 *nbuffers = VPBE_DEFAULT_NUM_BUFS - vq->num_buffers;
237 return sizes[0] < layer->pix_fmt.sizeimage ? -EINVAL : 0;
240 sizes[0] = layer->pix_fmt.sizeimage;
246 * vpbe_buffer_queue()
247 * This function adds the buffer to DMA queue
249 static void vpbe_buffer_queue(struct vb2_buffer *vb)
251 struct vb2_v4l2_buffer *vbuf = to_vb2_v4l2_buffer(vb);
252 /* Get the file handle object and layer object */
253 struct vpbe_disp_buffer *buf = container_of(vbuf,
254 struct vpbe_disp_buffer, vb);
255 struct vpbe_layer *layer = vb2_get_drv_priv(vb->vb2_queue);
256 struct vpbe_display *disp = layer->disp_dev;
257 struct vpbe_device *vpbe_dev = layer->disp_dev->vpbe_dev;
260 v4l2_dbg(1, debug, &vpbe_dev->v4l2_dev,
261 "vpbe_buffer_queue\n");
263 /* add the buffer to the DMA queue */
264 spin_lock_irqsave(&disp->dma_queue_lock, flags);
265 list_add_tail(&buf->list, &layer->dma_queue);
266 spin_unlock_irqrestore(&disp->dma_queue_lock, flags);
269 static int vpbe_start_streaming(struct vb2_queue *vq, unsigned int count)
271 struct vpbe_layer *layer = vb2_get_drv_priv(vq);
272 struct osd_state *osd_device = layer->disp_dev->osd_device;
275 osd_device->ops.disable_layer(osd_device, layer->layer_info.id);
277 /* Get the next frame from the buffer queue */
278 layer->next_frm = layer->cur_frm = list_entry(layer->dma_queue.next,
279 struct vpbe_disp_buffer, list);
280 /* Remove buffer from the buffer queue */
281 list_del(&layer->cur_frm->list);
282 /* Mark state of the current frame to active */
283 layer->cur_frm->vb.vb2_buf.state = VB2_BUF_STATE_ACTIVE;
284 /* Initialize field_id and started member */
287 /* Set parameters in OSD and VENC */
288 ret = vpbe_set_osd_display_params(layer->disp_dev, layer);
290 struct vpbe_disp_buffer *buf, *tmp;
292 vb2_buffer_done(&layer->cur_frm->vb.vb2_buf,
293 VB2_BUF_STATE_QUEUED);
294 list_for_each_entry_safe(buf, tmp, &layer->dma_queue, list) {
295 list_del(&buf->list);
296 vb2_buffer_done(&buf->vb.vb2_buf,
297 VB2_BUF_STATE_QUEUED);
304 * if request format is yuv420 semiplanar, need to
305 * enable both video windows
307 layer->layer_first_int = 1;
312 static void vpbe_stop_streaming(struct vb2_queue *vq)
314 struct vpbe_layer *layer = vb2_get_drv_priv(vq);
315 struct osd_state *osd_device = layer->disp_dev->osd_device;
316 struct vpbe_display *disp = layer->disp_dev;
319 if (!vb2_is_streaming(vq))
322 osd_device->ops.disable_layer(osd_device, layer->layer_info.id);
324 /* release all active buffers */
325 spin_lock_irqsave(&disp->dma_queue_lock, flags);
326 if (layer->cur_frm == layer->next_frm) {
327 vb2_buffer_done(&layer->cur_frm->vb.vb2_buf,
328 VB2_BUF_STATE_ERROR);
331 vb2_buffer_done(&layer->cur_frm->vb.vb2_buf,
332 VB2_BUF_STATE_ERROR);
334 vb2_buffer_done(&layer->next_frm->vb.vb2_buf,
335 VB2_BUF_STATE_ERROR);
338 while (!list_empty(&layer->dma_queue)) {
339 layer->next_frm = list_entry(layer->dma_queue.next,
340 struct vpbe_disp_buffer, list);
341 list_del(&layer->next_frm->list);
342 vb2_buffer_done(&layer->next_frm->vb.vb2_buf,
343 VB2_BUF_STATE_ERROR);
345 spin_unlock_irqrestore(&disp->dma_queue_lock, flags);
348 static const struct vb2_ops video_qops = {
349 .queue_setup = vpbe_buffer_queue_setup,
350 .wait_prepare = vb2_ops_wait_prepare,
351 .wait_finish = vb2_ops_wait_finish,
352 .buf_prepare = vpbe_buffer_prepare,
353 .start_streaming = vpbe_start_streaming,
354 .stop_streaming = vpbe_stop_streaming,
355 .buf_queue = vpbe_buffer_queue,
360 _vpbe_display_get_other_win_layer(struct vpbe_display *disp_dev,
361 struct vpbe_layer *layer)
363 enum vpbe_display_device_id thiswin, otherwin;
364 thiswin = layer->device_id;
366 otherwin = (thiswin == VPBE_DISPLAY_DEVICE_0) ?
367 VPBE_DISPLAY_DEVICE_1 : VPBE_DISPLAY_DEVICE_0;
368 return disp_dev->dev[otherwin];
371 static int vpbe_set_osd_display_params(struct vpbe_display *disp_dev,
372 struct vpbe_layer *layer)
374 struct osd_layer_config *cfg = &layer->layer_info.config;
375 struct osd_state *osd_device = disp_dev->osd_device;
376 struct vpbe_device *vpbe_dev = disp_dev->vpbe_dev;
380 addr = vb2_dma_contig_plane_dma_addr(&layer->cur_frm->vb.vb2_buf, 0);
381 /* Set address in the display registers */
382 osd_device->ops.start_layer(osd_device,
383 layer->layer_info.id,
385 disp_dev->cbcr_ofst);
387 ret = osd_device->ops.enable_layer(osd_device,
388 layer->layer_info.id, 0);
390 v4l2_err(&vpbe_dev->v4l2_dev,
391 "Error in enabling osd window layer 0\n");
395 /* Enable the window */
396 layer->layer_info.enable = 1;
397 if (cfg->pixfmt == PIXFMT_NV12) {
398 struct vpbe_layer *otherlayer =
399 _vpbe_display_get_other_win_layer(disp_dev, layer);
401 ret = osd_device->ops.enable_layer(osd_device,
402 otherlayer->layer_info.id, 1);
404 v4l2_err(&vpbe_dev->v4l2_dev,
405 "Error in enabling osd window layer 1\n");
408 otherlayer->layer_info.enable = 1;
414 vpbe_disp_calculate_scale_factor(struct vpbe_display *disp_dev,
415 struct vpbe_layer *layer,
416 int expected_xsize, int expected_ysize)
418 struct display_layer_info *layer_info = &layer->layer_info;
419 struct v4l2_pix_format *pixfmt = &layer->pix_fmt;
420 struct osd_layer_config *cfg = &layer->layer_info.config;
421 struct vpbe_device *vpbe_dev = disp_dev->vpbe_dev;
422 int calculated_xsize;
428 v4l2_std_id standard_id = vpbe_dev->current_timings.std_id;
431 * Application initially set the image format. Current display
432 * size is obtained from the vpbe display controller. expected_xsize
433 * and expected_ysize are set through S_SELECTION ioctl. Based on this,
434 * driver will calculate the scale factors for vertical and
435 * horizontal direction so that the image is displayed scaled
436 * and expanded. Application uses expansion to display the image
437 * in a square pixel. Otherwise it is displayed using displays
438 * pixel aspect ratio.It is expected that application chooses
439 * the crop coordinates for cropped or scaled display. if crop
440 * size is less than the image size, it is displayed cropped or
441 * it is displayed scaled and/or expanded.
443 * to begin with, set the crop window same as expected. Later we
444 * will override with scaled window size
447 cfg->xsize = pixfmt->width;
448 cfg->ysize = pixfmt->height;
449 layer_info->h_zoom = ZOOM_X1; /* no horizontal zoom */
450 layer_info->v_zoom = ZOOM_X1; /* no horizontal zoom */
451 layer_info->h_exp = H_EXP_OFF; /* no horizontal zoom */
452 layer_info->v_exp = V_EXP_OFF; /* no horizontal zoom */
454 if (pixfmt->width < expected_xsize) {
455 h_scale = vpbe_dev->current_timings.xres / pixfmt->width;
458 else if (h_scale >= 4)
462 cfg->xsize *= h_scale;
463 if (cfg->xsize < expected_xsize) {
464 if ((standard_id & V4L2_STD_525_60) ||
465 (standard_id & V4L2_STD_625_50)) {
466 calculated_xsize = (cfg->xsize *
467 VPBE_DISPLAY_H_EXP_RATIO_N) /
468 VPBE_DISPLAY_H_EXP_RATIO_D;
469 if (calculated_xsize <= expected_xsize) {
471 cfg->xsize = calculated_xsize;
476 layer_info->h_zoom = ZOOM_X2;
477 else if (h_scale == 4)
478 layer_info->h_zoom = ZOOM_X4;
480 layer_info->h_exp = H_EXP_9_OVER_8;
482 /* no scaling, only cropping. Set display area to crop area */
483 cfg->xsize = expected_xsize;
486 if (pixfmt->height < expected_ysize) {
487 v_scale = expected_ysize / pixfmt->height;
490 else if (v_scale >= 4)
494 cfg->ysize *= v_scale;
495 if (cfg->ysize < expected_ysize) {
496 if ((standard_id & V4L2_STD_625_50)) {
497 calculated_xsize = (cfg->ysize *
498 VPBE_DISPLAY_V_EXP_RATIO_N) /
499 VPBE_DISPLAY_V_EXP_RATIO_D;
500 if (calculated_xsize <= expected_ysize) {
502 cfg->ysize = calculated_xsize;
507 layer_info->v_zoom = ZOOM_X2;
508 else if (v_scale == 4)
509 layer_info->v_zoom = ZOOM_X4;
511 layer_info->v_exp = V_EXP_6_OVER_5;
513 /* no scaling, only cropping. Set display area to crop area */
514 cfg->ysize = expected_ysize;
516 v4l2_dbg(1, debug, &vpbe_dev->v4l2_dev,
517 "crop display xsize = %d, ysize = %d\n",
518 cfg->xsize, cfg->ysize);
521 static void vpbe_disp_adj_position(struct vpbe_display *disp_dev,
522 struct vpbe_layer *layer,
525 struct osd_layer_config *cfg = &layer->layer_info.config;
526 struct vpbe_device *vpbe_dev = disp_dev->vpbe_dev;
528 cfg->xpos = min((unsigned int)left,
529 vpbe_dev->current_timings.xres - cfg->xsize);
530 cfg->ypos = min((unsigned int)top,
531 vpbe_dev->current_timings.yres - cfg->ysize);
533 v4l2_dbg(1, debug, &vpbe_dev->v4l2_dev,
534 "new xpos = %d, ypos = %d\n",
535 cfg->xpos, cfg->ypos);
538 static void vpbe_disp_check_window_params(struct vpbe_display *disp_dev,
541 struct vpbe_device *vpbe_dev = disp_dev->vpbe_dev;
543 if ((c->width == 0) ||
544 ((c->width + c->left) > vpbe_dev->current_timings.xres))
545 c->width = vpbe_dev->current_timings.xres - c->left;
547 if ((c->height == 0) || ((c->height + c->top) >
548 vpbe_dev->current_timings.yres))
549 c->height = vpbe_dev->current_timings.yres - c->top;
551 /* window height must be even for interlaced display */
552 if (vpbe_dev->current_timings.interlaced)
553 c->height &= (~0x01);
559 * If user application provides width and height, and have bytesperline set
560 * to zero, driver calculates bytesperline and sizeimage based on hardware
563 static int vpbe_try_format(struct vpbe_display *disp_dev,
564 struct v4l2_pix_format *pixfmt, int check)
566 struct vpbe_device *vpbe_dev = disp_dev->vpbe_dev;
573 if ((pixfmt->pixelformat != V4L2_PIX_FMT_UYVY) &&
574 (pixfmt->pixelformat != V4L2_PIX_FMT_NV12))
575 /* choose default as V4L2_PIX_FMT_UYVY */
576 pixfmt->pixelformat = V4L2_PIX_FMT_UYVY;
578 /* Check the field format */
579 if ((pixfmt->field != V4L2_FIELD_INTERLACED) &&
580 (pixfmt->field != V4L2_FIELD_NONE)) {
581 if (vpbe_dev->current_timings.interlaced)
582 pixfmt->field = V4L2_FIELD_INTERLACED;
584 pixfmt->field = V4L2_FIELD_NONE;
587 if (pixfmt->field == V4L2_FIELD_INTERLACED)
590 if (pixfmt->pixelformat == V4L2_PIX_FMT_NV12)
595 max_width = vpbe_dev->current_timings.xres;
596 max_height = vpbe_dev->current_timings.yres;
600 if (!pixfmt->width || (pixfmt->width < min_width) ||
601 (pixfmt->width > max_width)) {
602 pixfmt->width = vpbe_dev->current_timings.xres;
605 if (!pixfmt->height || (pixfmt->height < min_height) ||
606 (pixfmt->height > max_height)) {
607 pixfmt->height = vpbe_dev->current_timings.yres;
610 if (pixfmt->bytesperline < (pixfmt->width * bpp))
611 pixfmt->bytesperline = pixfmt->width * bpp;
613 /* Make the bytesperline 32 byte aligned */
614 pixfmt->bytesperline = ((pixfmt->width * bpp + 31) & ~31);
616 if (pixfmt->pixelformat == V4L2_PIX_FMT_NV12)
617 pixfmt->sizeimage = pixfmt->bytesperline * pixfmt->height +
618 (pixfmt->bytesperline * pixfmt->height >> 1);
620 pixfmt->sizeimage = pixfmt->bytesperline * pixfmt->height;
625 static int vpbe_display_querycap(struct file *file, void *priv,
626 struct v4l2_capability *cap)
628 struct vpbe_layer *layer = video_drvdata(file);
629 struct vpbe_device *vpbe_dev = layer->disp_dev->vpbe_dev;
631 snprintf(cap->driver, sizeof(cap->driver), "%s",
632 dev_name(vpbe_dev->pdev));
633 strscpy(cap->card, vpbe_dev->cfg->module_name, sizeof(cap->card));
638 static int vpbe_display_s_selection(struct file *file, void *priv,
639 struct v4l2_selection *sel)
641 struct vpbe_layer *layer = video_drvdata(file);
642 struct vpbe_display *disp_dev = layer->disp_dev;
643 struct vpbe_device *vpbe_dev = disp_dev->vpbe_dev;
644 struct osd_layer_config *cfg = &layer->layer_info.config;
645 struct osd_state *osd_device = disp_dev->osd_device;
646 struct v4l2_rect rect = sel->r;
649 v4l2_dbg(1, debug, &vpbe_dev->v4l2_dev,
650 "VIDIOC_S_SELECTION, layer id = %d\n", layer->device_id);
652 if (sel->type != V4L2_BUF_TYPE_VIDEO_OUTPUT ||
653 sel->target != V4L2_SEL_TGT_CROP)
661 vpbe_disp_check_window_params(disp_dev, &rect);
663 osd_device->ops.get_layer_config(osd_device,
664 layer->layer_info.id, cfg);
666 vpbe_disp_calculate_scale_factor(disp_dev, layer,
669 vpbe_disp_adj_position(disp_dev, layer, rect.top,
671 ret = osd_device->ops.set_layer_config(osd_device,
672 layer->layer_info.id, cfg);
674 v4l2_err(&vpbe_dev->v4l2_dev,
675 "Error in set layer config:\n");
679 /* apply zooming and h or v expansion */
680 osd_device->ops.set_zoom(osd_device,
681 layer->layer_info.id,
682 layer->layer_info.h_zoom,
683 layer->layer_info.v_zoom);
684 ret = osd_device->ops.set_vid_expansion(osd_device,
685 layer->layer_info.h_exp,
686 layer->layer_info.v_exp);
688 v4l2_err(&vpbe_dev->v4l2_dev,
689 "Error in set vid expansion:\n");
693 if ((layer->layer_info.h_zoom != ZOOM_X1) ||
694 (layer->layer_info.v_zoom != ZOOM_X1) ||
695 (layer->layer_info.h_exp != H_EXP_OFF) ||
696 (layer->layer_info.v_exp != V_EXP_OFF))
697 /* Enable expansion filter */
698 osd_device->ops.set_interpolation_filter(osd_device, 1);
700 osd_device->ops.set_interpolation_filter(osd_device, 0);
706 static int vpbe_display_g_selection(struct file *file, void *priv,
707 struct v4l2_selection *sel)
709 struct vpbe_layer *layer = video_drvdata(file);
710 struct osd_layer_config *cfg = &layer->layer_info.config;
711 struct vpbe_device *vpbe_dev = layer->disp_dev->vpbe_dev;
712 struct osd_state *osd_device = layer->disp_dev->osd_device;
713 struct v4l2_rect *rect = &sel->r;
715 v4l2_dbg(1, debug, &vpbe_dev->v4l2_dev,
716 "VIDIOC_G_SELECTION, layer id = %d\n",
719 if (sel->type != V4L2_BUF_TYPE_VIDEO_OUTPUT)
722 switch (sel->target) {
723 case V4L2_SEL_TGT_CROP:
724 osd_device->ops.get_layer_config(osd_device,
725 layer->layer_info.id, cfg);
726 rect->top = cfg->ypos;
727 rect->left = cfg->xpos;
728 rect->width = cfg->xsize;
729 rect->height = cfg->ysize;
731 case V4L2_SEL_TGT_CROP_DEFAULT:
732 case V4L2_SEL_TGT_CROP_BOUNDS:
735 rect->width = vpbe_dev->current_timings.xres;
736 rect->height = vpbe_dev->current_timings.yres;
745 static int vpbe_display_g_pixelaspect(struct file *file, void *priv,
746 int type, struct v4l2_fract *f)
748 struct vpbe_layer *layer = video_drvdata(file);
749 struct vpbe_device *vpbe_dev = layer->disp_dev->vpbe_dev;
751 v4l2_dbg(1, debug, &vpbe_dev->v4l2_dev, "VIDIOC_CROPCAP ioctl\n");
753 if (type != V4L2_BUF_TYPE_VIDEO_OUTPUT)
756 *f = vpbe_dev->current_timings.aspect;
760 static int vpbe_display_g_fmt(struct file *file, void *priv,
761 struct v4l2_format *fmt)
763 struct vpbe_layer *layer = video_drvdata(file);
764 struct vpbe_device *vpbe_dev = layer->disp_dev->vpbe_dev;
766 v4l2_dbg(1, debug, &vpbe_dev->v4l2_dev,
767 "VIDIOC_G_FMT, layer id = %d\n",
770 /* If buffer type is video output */
771 if (V4L2_BUF_TYPE_VIDEO_OUTPUT != fmt->type) {
772 v4l2_err(&vpbe_dev->v4l2_dev, "invalid type\n");
775 /* Fill in the information about format */
776 fmt->fmt.pix = layer->pix_fmt;
781 static int vpbe_display_enum_fmt(struct file *file, void *priv,
782 struct v4l2_fmtdesc *fmt)
784 struct vpbe_layer *layer = video_drvdata(file);
785 struct vpbe_device *vpbe_dev = layer->disp_dev->vpbe_dev;
787 v4l2_dbg(1, debug, &vpbe_dev->v4l2_dev,
788 "VIDIOC_ENUM_FMT, layer id = %d\n",
790 if (fmt->index > 1) {
791 v4l2_err(&vpbe_dev->v4l2_dev, "Invalid format index\n");
795 /* Fill in the information about format */
797 fmt->pixelformat = V4L2_PIX_FMT_UYVY;
799 fmt->pixelformat = V4L2_PIX_FMT_NV12;
804 static int vpbe_display_s_fmt(struct file *file, void *priv,
805 struct v4l2_format *fmt)
807 struct vpbe_layer *layer = video_drvdata(file);
808 struct vpbe_display *disp_dev = layer->disp_dev;
809 struct vpbe_device *vpbe_dev = disp_dev->vpbe_dev;
810 struct osd_layer_config *cfg = &layer->layer_info.config;
811 struct v4l2_pix_format *pixfmt = &fmt->fmt.pix;
812 struct osd_state *osd_device = disp_dev->osd_device;
815 v4l2_dbg(1, debug, &vpbe_dev->v4l2_dev,
816 "VIDIOC_S_FMT, layer id = %d\n",
819 if (vb2_is_busy(&layer->buffer_queue))
822 if (V4L2_BUF_TYPE_VIDEO_OUTPUT != fmt->type) {
823 v4l2_dbg(1, debug, &vpbe_dev->v4l2_dev, "invalid type\n");
826 /* Check for valid pixel format */
827 ret = vpbe_try_format(disp_dev, pixfmt, 1);
831 /* YUV420 is requested, check availability of the
832 other video window */
834 layer->pix_fmt = *pixfmt;
835 if (pixfmt->pixelformat == V4L2_PIX_FMT_NV12) {
836 struct vpbe_layer *otherlayer;
838 otherlayer = _vpbe_display_get_other_win_layer(disp_dev, layer);
839 /* if other layer is available, only
840 * claim it, do not configure it
842 ret = osd_device->ops.request_layer(osd_device,
843 otherlayer->layer_info.id);
845 v4l2_err(&vpbe_dev->v4l2_dev,
846 "Display Manager failed to allocate layer\n");
851 /* Get osd layer config */
852 osd_device->ops.get_layer_config(osd_device,
853 layer->layer_info.id, cfg);
854 /* Store the pixel format in the layer object */
855 cfg->xsize = pixfmt->width;
856 cfg->ysize = pixfmt->height;
857 cfg->line_length = pixfmt->bytesperline;
860 cfg->interlaced = vpbe_dev->current_timings.interlaced;
862 if (V4L2_PIX_FMT_UYVY == pixfmt->pixelformat)
863 cfg->pixfmt = PIXFMT_YCBCRI;
865 /* Change of the default pixel format for both video windows */
866 if (V4L2_PIX_FMT_NV12 == pixfmt->pixelformat) {
867 struct vpbe_layer *otherlayer;
868 cfg->pixfmt = PIXFMT_NV12;
869 otherlayer = _vpbe_display_get_other_win_layer(disp_dev,
871 otherlayer->layer_info.config.pixfmt = PIXFMT_NV12;
874 /* Set the layer config in the osd window */
875 ret = osd_device->ops.set_layer_config(osd_device,
876 layer->layer_info.id, cfg);
878 v4l2_err(&vpbe_dev->v4l2_dev,
879 "Error in S_FMT params:\n");
883 /* Readback and fill the local copy of current pix format */
884 osd_device->ops.get_layer_config(osd_device,
885 layer->layer_info.id, cfg);
890 static int vpbe_display_try_fmt(struct file *file, void *priv,
891 struct v4l2_format *fmt)
893 struct vpbe_layer *layer = video_drvdata(file);
894 struct vpbe_display *disp_dev = layer->disp_dev;
895 struct vpbe_device *vpbe_dev = layer->disp_dev->vpbe_dev;
896 struct v4l2_pix_format *pixfmt = &fmt->fmt.pix;
898 v4l2_dbg(1, debug, &vpbe_dev->v4l2_dev, "VIDIOC_TRY_FMT\n");
900 if (V4L2_BUF_TYPE_VIDEO_OUTPUT != fmt->type) {
901 v4l2_err(&vpbe_dev->v4l2_dev, "invalid type\n");
905 /* Check for valid field format */
906 return vpbe_try_format(disp_dev, pixfmt, 0);
911 * vpbe_display_s_std - Set the given standard in the encoder
913 * Sets the standard if supported by the current encoder. Return the status.
914 * 0 - success & -EINVAL on error
916 static int vpbe_display_s_std(struct file *file, void *priv,
919 struct vpbe_layer *layer = video_drvdata(file);
920 struct vpbe_device *vpbe_dev = layer->disp_dev->vpbe_dev;
923 v4l2_dbg(1, debug, &vpbe_dev->v4l2_dev, "VIDIOC_S_STD\n");
925 if (vb2_is_busy(&layer->buffer_queue))
928 if (vpbe_dev->ops.s_std) {
929 ret = vpbe_dev->ops.s_std(vpbe_dev, std_id);
931 v4l2_err(&vpbe_dev->v4l2_dev,
932 "Failed to set standard for sub devices\n");
943 * vpbe_display_g_std - Get the standard in the current encoder
945 * Get the standard in the current encoder. Return the status. 0 - success
948 static int vpbe_display_g_std(struct file *file, void *priv,
951 struct vpbe_layer *layer = video_drvdata(file);
952 struct vpbe_device *vpbe_dev = layer->disp_dev->vpbe_dev;
954 v4l2_dbg(1, debug, &vpbe_dev->v4l2_dev, "VIDIOC_G_STD\n");
956 /* Get the standard from the current encoder */
957 if (vpbe_dev->current_timings.timings_type & VPBE_ENC_STD) {
958 *std_id = vpbe_dev->current_timings.std_id;
966 * vpbe_display_enum_output - enumerate outputs
968 * Enumerates the outputs available at the vpbe display
969 * returns the status, -EINVAL if end of output list
971 static int vpbe_display_enum_output(struct file *file, void *priv,
972 struct v4l2_output *output)
974 struct vpbe_layer *layer = video_drvdata(file);
975 struct vpbe_device *vpbe_dev = layer->disp_dev->vpbe_dev;
978 v4l2_dbg(1, debug, &vpbe_dev->v4l2_dev, "VIDIOC_ENUM_OUTPUT\n");
980 /* Enumerate outputs */
981 if (!vpbe_dev->ops.enum_outputs)
984 ret = vpbe_dev->ops.enum_outputs(vpbe_dev, output);
986 v4l2_dbg(1, debug, &vpbe_dev->v4l2_dev,
987 "Failed to enumerate outputs\n");
995 * vpbe_display_s_output - Set output to
996 * the output specified by the index
998 static int vpbe_display_s_output(struct file *file, void *priv,
1001 struct vpbe_layer *layer = video_drvdata(file);
1002 struct vpbe_device *vpbe_dev = layer->disp_dev->vpbe_dev;
1005 v4l2_dbg(1, debug, &vpbe_dev->v4l2_dev, "VIDIOC_S_OUTPUT\n");
1007 if (vb2_is_busy(&layer->buffer_queue))
1010 if (!vpbe_dev->ops.set_output)
1013 ret = vpbe_dev->ops.set_output(vpbe_dev, i);
1015 v4l2_err(&vpbe_dev->v4l2_dev,
1016 "Failed to set output for sub devices\n");
1024 * vpbe_display_g_output - Get output from subdevice
1025 * for a given by the index
1027 static int vpbe_display_g_output(struct file *file, void *priv,
1030 struct vpbe_layer *layer = video_drvdata(file);
1031 struct vpbe_device *vpbe_dev = layer->disp_dev->vpbe_dev;
1033 v4l2_dbg(1, debug, &vpbe_dev->v4l2_dev, "VIDIOC_G_OUTPUT\n");
1034 /* Get the standard from the current encoder */
1035 *i = vpbe_dev->current_out_index;
1041 * vpbe_display_enum_dv_timings - Enumerate the dv timings
1043 * enum the timings in the current encoder. Return the status. 0 - success
1047 vpbe_display_enum_dv_timings(struct file *file, void *priv,
1048 struct v4l2_enum_dv_timings *timings)
1050 struct vpbe_layer *layer = video_drvdata(file);
1051 struct vpbe_device *vpbe_dev = layer->disp_dev->vpbe_dev;
1054 v4l2_dbg(1, debug, &vpbe_dev->v4l2_dev, "VIDIOC_ENUM_DV_TIMINGS\n");
1056 /* Enumerate outputs */
1057 if (!vpbe_dev->ops.enum_dv_timings)
1060 ret = vpbe_dev->ops.enum_dv_timings(vpbe_dev, timings);
1062 v4l2_err(&vpbe_dev->v4l2_dev,
1063 "Failed to enumerate dv timings info\n");
1071 * vpbe_display_s_dv_timings - Set the dv timings
1073 * Set the timings in the current encoder. Return the status. 0 - success
1077 vpbe_display_s_dv_timings(struct file *file, void *priv,
1078 struct v4l2_dv_timings *timings)
1080 struct vpbe_layer *layer = video_drvdata(file);
1081 struct vpbe_device *vpbe_dev = layer->disp_dev->vpbe_dev;
1084 v4l2_dbg(1, debug, &vpbe_dev->v4l2_dev, "VIDIOC_S_DV_TIMINGS\n");
1086 if (vb2_is_busy(&layer->buffer_queue))
1089 /* Set the given standard in the encoder */
1090 if (!vpbe_dev->ops.s_dv_timings)
1093 ret = vpbe_dev->ops.s_dv_timings(vpbe_dev, timings);
1095 v4l2_err(&vpbe_dev->v4l2_dev,
1096 "Failed to set the dv timings info\n");
1104 * vpbe_display_g_dv_timings - Set the dv timings
1106 * Get the timings in the current encoder. Return the status. 0 - success
1110 vpbe_display_g_dv_timings(struct file *file, void *priv,
1111 struct v4l2_dv_timings *dv_timings)
1113 struct vpbe_layer *layer = video_drvdata(file);
1114 struct vpbe_device *vpbe_dev = layer->disp_dev->vpbe_dev;
1116 v4l2_dbg(1, debug, &vpbe_dev->v4l2_dev, "VIDIOC_G_DV_TIMINGS\n");
1118 /* Get the given standard in the encoder */
1120 if (vpbe_dev->current_timings.timings_type &
1121 VPBE_ENC_DV_TIMINGS) {
1122 *dv_timings = vpbe_dev->current_timings.dv_timings;
1131 * vpbe_display_open()
1132 * It creates object of file handle structure and stores it in private_data
1133 * member of filepointer
1135 static int vpbe_display_open(struct file *file)
1137 struct vpbe_layer *layer = video_drvdata(file);
1138 struct vpbe_display *disp_dev = layer->disp_dev;
1139 struct vpbe_device *vpbe_dev = disp_dev->vpbe_dev;
1140 struct osd_state *osd_device = disp_dev->osd_device;
1143 /* creating context for file descriptor */
1144 err = v4l2_fh_open(file);
1146 v4l2_err(&vpbe_dev->v4l2_dev, "v4l2_fh_open failed\n");
1150 /* leaving if layer is already initialized */
1151 if (!v4l2_fh_is_singular_file(file))
1155 if (mutex_lock_interruptible(&layer->opslock))
1156 return -ERESTARTSYS;
1157 /* First claim the layer for this device */
1158 err = osd_device->ops.request_layer(osd_device,
1159 layer->layer_info.id);
1160 mutex_unlock(&layer->opslock);
1162 /* Couldn't get layer */
1163 v4l2_err(&vpbe_dev->v4l2_dev,
1164 "Display Manager failed to allocate layer\n");
1165 v4l2_fh_release(file);
1169 /* Increment layer usrs counter */
1171 v4l2_dbg(1, debug, &vpbe_dev->v4l2_dev,
1172 "vpbe display device opened successfully\n");
1177 * vpbe_display_release()
1178 * This function deletes buffer queue, frees the buffers and the davinci
1179 * display file * handle
1181 static int vpbe_display_release(struct file *file)
1183 struct vpbe_layer *layer = video_drvdata(file);
1184 struct osd_layer_config *cfg = &layer->layer_info.config;
1185 struct vpbe_display *disp_dev = layer->disp_dev;
1186 struct vpbe_device *vpbe_dev = disp_dev->vpbe_dev;
1187 struct osd_state *osd_device = disp_dev->osd_device;
1189 v4l2_dbg(1, debug, &vpbe_dev->v4l2_dev, "vpbe_display_release\n");
1191 mutex_lock(&layer->opslock);
1193 osd_device->ops.disable_layer(osd_device,
1194 layer->layer_info.id);
1195 /* Decrement layer usrs counter */
1197 /* If this file handle has initialize encoder device, reset it */
1199 if (cfg->pixfmt == PIXFMT_NV12) {
1200 struct vpbe_layer *otherlayer;
1202 _vpbe_display_get_other_win_layer(disp_dev, layer);
1203 osd_device->ops.disable_layer(osd_device,
1204 otherlayer->layer_info.id);
1205 osd_device->ops.release_layer(osd_device,
1206 otherlayer->layer_info.id);
1208 osd_device->ops.disable_layer(osd_device,
1209 layer->layer_info.id);
1210 osd_device->ops.release_layer(osd_device,
1211 layer->layer_info.id);
1214 _vb2_fop_release(file, NULL);
1215 mutex_unlock(&layer->opslock);
1217 disp_dev->cbcr_ofst = 0;
1222 /* vpbe capture ioctl operations */
1223 static const struct v4l2_ioctl_ops vpbe_ioctl_ops = {
1224 .vidioc_querycap = vpbe_display_querycap,
1225 .vidioc_g_fmt_vid_out = vpbe_display_g_fmt,
1226 .vidioc_enum_fmt_vid_out = vpbe_display_enum_fmt,
1227 .vidioc_s_fmt_vid_out = vpbe_display_s_fmt,
1228 .vidioc_try_fmt_vid_out = vpbe_display_try_fmt,
1230 .vidioc_reqbufs = vb2_ioctl_reqbufs,
1231 .vidioc_create_bufs = vb2_ioctl_create_bufs,
1232 .vidioc_querybuf = vb2_ioctl_querybuf,
1233 .vidioc_qbuf = vb2_ioctl_qbuf,
1234 .vidioc_dqbuf = vb2_ioctl_dqbuf,
1235 .vidioc_streamon = vb2_ioctl_streamon,
1236 .vidioc_streamoff = vb2_ioctl_streamoff,
1237 .vidioc_expbuf = vb2_ioctl_expbuf,
1239 .vidioc_g_pixelaspect = vpbe_display_g_pixelaspect,
1240 .vidioc_g_selection = vpbe_display_g_selection,
1241 .vidioc_s_selection = vpbe_display_s_selection,
1243 .vidioc_s_std = vpbe_display_s_std,
1244 .vidioc_g_std = vpbe_display_g_std,
1246 .vidioc_enum_output = vpbe_display_enum_output,
1247 .vidioc_s_output = vpbe_display_s_output,
1248 .vidioc_g_output = vpbe_display_g_output,
1250 .vidioc_s_dv_timings = vpbe_display_s_dv_timings,
1251 .vidioc_g_dv_timings = vpbe_display_g_dv_timings,
1252 .vidioc_enum_dv_timings = vpbe_display_enum_dv_timings,
1255 static const struct v4l2_file_operations vpbe_fops = {
1256 .owner = THIS_MODULE,
1257 .open = vpbe_display_open,
1258 .release = vpbe_display_release,
1259 .unlocked_ioctl = video_ioctl2,
1260 .mmap = vb2_fop_mmap,
1261 .poll = vb2_fop_poll,
1264 static int vpbe_device_get(struct device *dev, void *data)
1266 struct platform_device *pdev = to_platform_device(dev);
1267 struct vpbe_display *vpbe_disp = data;
1269 if (strcmp("vpbe_controller", pdev->name) == 0)
1270 vpbe_disp->vpbe_dev = platform_get_drvdata(pdev);
1272 if (strstr(pdev->name, "vpbe-osd"))
1273 vpbe_disp->osd_device = platform_get_drvdata(pdev);
1278 static int init_vpbe_layer(int i, struct vpbe_display *disp_dev,
1279 struct platform_device *pdev)
1281 struct vpbe_layer *vpbe_display_layer = NULL;
1282 struct video_device *vbd = NULL;
1284 /* Allocate memory for four plane display objects */
1285 disp_dev->dev[i] = kzalloc(sizeof(*disp_dev->dev[i]), GFP_KERNEL);
1286 if (!disp_dev->dev[i])
1289 spin_lock_init(&disp_dev->dev[i]->irqlock);
1290 mutex_init(&disp_dev->dev[i]->opslock);
1292 /* Get the pointer to the layer object */
1293 vpbe_display_layer = disp_dev->dev[i];
1294 vbd = &vpbe_display_layer->video_dev;
1295 /* Initialize field of video device */
1296 vbd->release = video_device_release_empty;
1297 vbd->fops = &vpbe_fops;
1298 vbd->ioctl_ops = &vpbe_ioctl_ops;
1300 vbd->v4l2_dev = &disp_dev->vpbe_dev->v4l2_dev;
1301 vbd->lock = &vpbe_display_layer->opslock;
1302 vbd->vfl_dir = VFL_DIR_TX;
1303 vbd->device_caps = V4L2_CAP_VIDEO_OUTPUT | V4L2_CAP_STREAMING;
1305 if (disp_dev->vpbe_dev->current_timings.timings_type &
1307 vbd->tvnorms = (V4L2_STD_525_60 | V4L2_STD_625_50);
1309 snprintf(vbd->name, sizeof(vbd->name),
1310 "DaVinci_VPBE Display_DRIVER_V%d.%d.%d",
1311 (VPBE_DISPLAY_VERSION_CODE >> 16) & 0xff,
1312 (VPBE_DISPLAY_VERSION_CODE >> 8) & 0xff,
1313 (VPBE_DISPLAY_VERSION_CODE) & 0xff);
1315 vpbe_display_layer->device_id = i;
1317 vpbe_display_layer->layer_info.id =
1318 ((i == VPBE_DISPLAY_DEVICE_0) ? WIN_VID0 : WIN_VID1);
1324 static int register_device(struct vpbe_layer *vpbe_display_layer,
1325 struct vpbe_display *disp_dev,
1326 struct platform_device *pdev)
1330 v4l2_info(&disp_dev->vpbe_dev->v4l2_dev,
1331 "Trying to register VPBE display device.\n");
1332 v4l2_info(&disp_dev->vpbe_dev->v4l2_dev,
1333 "layer=%p,layer->video_dev=%p\n",
1335 &vpbe_display_layer->video_dev);
1337 vpbe_display_layer->video_dev.queue = &vpbe_display_layer->buffer_queue;
1338 err = video_register_device(&vpbe_display_layer->video_dev,
1344 vpbe_display_layer->disp_dev = disp_dev;
1345 /* set the driver data in platform device */
1346 platform_set_drvdata(pdev, disp_dev);
1347 video_set_drvdata(&vpbe_display_layer->video_dev,
1348 vpbe_display_layer);
1356 * vpbe_display_probe()
1357 * This function creates device entries by register itself to the V4L2 driver
1358 * and initializes fields of each layer objects
1360 static int vpbe_display_probe(struct platform_device *pdev)
1362 struct vpbe_display *disp_dev;
1363 struct v4l2_device *v4l2_dev;
1364 struct resource *res = NULL;
1365 struct vb2_queue *q;
1371 printk(KERN_DEBUG "vpbe_display_probe\n");
1372 /* Allocate memory for vpbe_display */
1373 disp_dev = devm_kzalloc(&pdev->dev, sizeof(*disp_dev), GFP_KERNEL);
1377 spin_lock_init(&disp_dev->dma_queue_lock);
1379 * Scan all the platform devices to find the vpbe
1380 * controller device and get the vpbe_dev object
1382 err = bus_for_each_dev(&platform_bus_type, NULL, disp_dev,
1387 v4l2_dev = &disp_dev->vpbe_dev->v4l2_dev;
1388 /* Initialize the vpbe display controller */
1389 if (disp_dev->vpbe_dev->ops.initialize) {
1390 err = disp_dev->vpbe_dev->ops.initialize(&pdev->dev,
1391 disp_dev->vpbe_dev);
1393 v4l2_err(v4l2_dev, "Error initing vpbe\n");
1399 for (i = 0; i < VPBE_DISPLAY_MAX_DEVICES; i++) {
1400 if (init_vpbe_layer(i, disp_dev, pdev)) {
1406 res = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
1408 v4l2_err(v4l2_dev, "Unable to get VENC interrupt resource\n");
1414 err = devm_request_irq(&pdev->dev, irq, venc_isr, 0,
1415 VPBE_DISPLAY_DRIVER, disp_dev);
1417 v4l2_err(v4l2_dev, "VPBE IRQ request failed\n");
1421 for (i = 0; i < VPBE_DISPLAY_MAX_DEVICES; i++) {
1422 /* initialize vb2 queue */
1423 q = &disp_dev->dev[i]->buffer_queue;
1424 memset(q, 0, sizeof(*q));
1425 q->type = V4L2_BUF_TYPE_VIDEO_OUTPUT;
1426 q->io_modes = VB2_MMAP | VB2_USERPTR | VB2_DMABUF;
1427 q->drv_priv = disp_dev->dev[i];
1428 q->ops = &video_qops;
1429 q->mem_ops = &vb2_dma_contig_memops;
1430 q->buf_struct_size = sizeof(struct vpbe_disp_buffer);
1431 q->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
1432 q->min_buffers_needed = 1;
1433 q->lock = &disp_dev->dev[i]->opslock;
1434 q->dev = disp_dev->vpbe_dev->pdev;
1435 err = vb2_queue_init(q);
1437 v4l2_err(v4l2_dev, "vb2_queue_init() failed\n");
1441 INIT_LIST_HEAD(&disp_dev->dev[i]->dma_queue);
1443 if (register_device(disp_dev->dev[i], disp_dev, pdev)) {
1449 v4l2_dbg(1, debug, v4l2_dev,
1450 "Successfully completed the probing of vpbe v4l2 device\n");
1455 for (k = 0; k < VPBE_DISPLAY_MAX_DEVICES; k++) {
1456 /* Unregister video device */
1457 if (disp_dev->dev[k]) {
1458 video_unregister_device(&disp_dev->dev[k]->video_dev);
1459 kfree(disp_dev->dev[k]);
1466 * vpbe_display_remove()
1467 * It un-register hardware layer from V4L2 driver
1469 static int vpbe_display_remove(struct platform_device *pdev)
1471 struct vpbe_layer *vpbe_display_layer;
1472 struct vpbe_display *disp_dev = platform_get_drvdata(pdev);
1473 struct vpbe_device *vpbe_dev = disp_dev->vpbe_dev;
1476 v4l2_dbg(1, debug, &vpbe_dev->v4l2_dev, "vpbe_display_remove\n");
1478 /* deinitialize the vpbe display controller */
1479 if (vpbe_dev->ops.deinitialize)
1480 vpbe_dev->ops.deinitialize(&pdev->dev, vpbe_dev);
1481 /* un-register device */
1482 for (i = 0; i < VPBE_DISPLAY_MAX_DEVICES; i++) {
1483 /* Get the pointer to the layer object */
1484 vpbe_display_layer = disp_dev->dev[i];
1485 /* Unregister video device */
1486 video_unregister_device(&vpbe_display_layer->video_dev);
1489 for (i = 0; i < VPBE_DISPLAY_MAX_DEVICES; i++) {
1490 kfree(disp_dev->dev[i]);
1491 disp_dev->dev[i] = NULL;
1497 static struct platform_driver vpbe_display_driver = {
1499 .name = VPBE_DISPLAY_DRIVER,
1500 .bus = &platform_bus_type,
1502 .probe = vpbe_display_probe,
1503 .remove = vpbe_display_remove,
1506 module_platform_driver(vpbe_display_driver);
1508 MODULE_DESCRIPTION("TI DM644x/DM355/DM365 VPBE Display controller");
1509 MODULE_LICENSE("GPL");
1510 MODULE_AUTHOR("Texas Instruments");