2 * vpif-display - VPIF display driver
3 * Display driver for TI DaVinci VPIF
5 * Copyright (C) 2009 Texas Instruments Incorporated - http://www.ti.com/
6 * Copyright (C) 2014 Lad, Prabhakar <prabhakar.csengg@gmail.com>
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License as
10 * published by the Free Software Foundation version 2.
12 * This program is distributed .as is. WITHOUT ANY WARRANTY of any
13 * kind, whether express or implied; without even the implied warranty
14 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
18 #include <linux/interrupt.h>
19 #include <linux/module.h>
20 #include <linux/platform_device.h>
21 #include <linux/slab.h>
23 #include <media/v4l2-ioctl.h>
26 #include "vpif_display.h"
28 MODULE_DESCRIPTION("TI DaVinci VPIF Display driver");
29 MODULE_LICENSE("GPL");
30 MODULE_VERSION(VPIF_DISPLAY_VERSION
);
32 #define VPIF_V4L2_STD (V4L2_STD_525_60 | V4L2_STD_625_50)
34 #define vpif_err(fmt, arg...) v4l2_err(&vpif_obj.v4l2_dev, fmt, ## arg)
35 #define vpif_dbg(level, debug, fmt, arg...) \
36 v4l2_dbg(level, debug, &vpif_obj.v4l2_dev, fmt, ## arg)
40 module_param(debug
, int, 0644);
42 MODULE_PARM_DESC(debug
, "Debug level 0-1");
44 #define VPIF_DRIVER_NAME "vpif_display"
46 /* Is set to 1 in case of SDTV formats, 2 in case of HDTV formats. */
47 static int ycmux_mode
;
49 static u8 channel_first_int
[VPIF_NUMOBJECTS
][2] = { {1, 1} };
51 static struct vpif_device vpif_obj
= { {NULL
} };
52 static struct device
*vpif_dev
;
53 static void vpif_calculate_offsets(struct channel_obj
*ch
);
54 static void vpif_config_addr(struct channel_obj
*ch
, int muxmode
);
57 struct vpif_disp_buffer
*to_vpif_buffer(struct vb2_v4l2_buffer
*vb
)
59 return container_of(vb
, struct vpif_disp_buffer
, vb
);
63 * vpif_buffer_prepare : callback function for buffer prepare
64 * @vb: ptr to vb2_buffer
66 * This is the callback function for buffer prepare when vb2_qbuf()
67 * function is called. The buffer is prepared and user space virtual address
68 * or user address is converted into physical address
70 static int vpif_buffer_prepare(struct vb2_buffer
*vb
)
72 struct vb2_v4l2_buffer
*vbuf
= to_vb2_v4l2_buffer(vb
);
73 struct channel_obj
*ch
= vb2_get_drv_priv(vb
->vb2_queue
);
74 struct common_obj
*common
;
76 common
= &ch
->common
[VPIF_VIDEO_INDEX
];
78 vb2_set_plane_payload(vb
, 0, common
->fmt
.fmt
.pix
.sizeimage
);
79 if (vb2_get_plane_payload(vb
, 0) > vb2_plane_size(vb
, 0))
82 vbuf
->field
= common
->fmt
.fmt
.pix
.field
;
84 if (vb
->vb2_queue
->type
!= V4L2_BUF_TYPE_SLICED_VBI_OUTPUT
) {
85 unsigned long addr
= vb2_dma_contig_plane_dma_addr(vb
, 0);
87 if (!ISALIGNED(addr
+ common
->ytop_off
) ||
88 !ISALIGNED(addr
+ common
->ybtm_off
) ||
89 !ISALIGNED(addr
+ common
->ctop_off
) ||
90 !ISALIGNED(addr
+ common
->cbtm_off
)) {
91 vpif_err("buffer offset not aligned to 8 bytes\n");
100 * vpif_buffer_queue_setup : Callback function for buffer setup.
102 * @nbuffers: ptr to number of buffers requested by application
103 * @nplanes:: contains number of distinct video planes needed to hold a frame
104 * @sizes[]: contains the size (in bytes) of each plane.
105 * @alloc_devs: ptr to allocation context
107 * This callback function is called when reqbuf() is called to adjust
108 * the buffer count and buffer size
110 static int vpif_buffer_queue_setup(struct vb2_queue
*vq
,
111 unsigned int *nbuffers
, unsigned int *nplanes
,
112 unsigned int sizes
[], struct device
*alloc_devs
[])
114 struct channel_obj
*ch
= vb2_get_drv_priv(vq
);
115 struct common_obj
*common
= &ch
->common
[VPIF_VIDEO_INDEX
];
116 unsigned size
= common
->fmt
.fmt
.pix
.sizeimage
;
124 if (vq
->num_buffers
+ *nbuffers
< 3)
125 *nbuffers
= 3 - vq
->num_buffers
;
130 /* Calculate the offset for Y and C data in the buffer */
131 vpif_calculate_offsets(ch
);
137 * vpif_buffer_queue : Callback function to add buffer to DMA queue
138 * @vb: ptr to vb2_buffer
140 * This callback fucntion queues the buffer to DMA engine
142 static void vpif_buffer_queue(struct vb2_buffer
*vb
)
144 struct vb2_v4l2_buffer
*vbuf
= to_vb2_v4l2_buffer(vb
);
145 struct vpif_disp_buffer
*buf
= to_vpif_buffer(vbuf
);
146 struct channel_obj
*ch
= vb2_get_drv_priv(vb
->vb2_queue
);
147 struct common_obj
*common
;
150 common
= &ch
->common
[VPIF_VIDEO_INDEX
];
152 /* add the buffer to the DMA queue */
153 spin_lock_irqsave(&common
->irqlock
, flags
);
154 list_add_tail(&buf
->list
, &common
->dma_queue
);
155 spin_unlock_irqrestore(&common
->irqlock
, flags
);
159 * vpif_start_streaming : Starts the DMA engine for streaming
160 * @vb: ptr to vb2_buffer
161 * @count: number of buffers
163 static int vpif_start_streaming(struct vb2_queue
*vq
, unsigned int count
)
165 struct vpif_display_config
*vpif_config_data
=
166 vpif_dev
->platform_data
;
167 struct channel_obj
*ch
= vb2_get_drv_priv(vq
);
168 struct common_obj
*common
= &ch
->common
[VPIF_VIDEO_INDEX
];
169 struct vpif_params
*vpif
= &ch
->vpifparams
;
170 struct vpif_disp_buffer
*buf
, *tmp
;
171 unsigned long addr
, flags
;
174 spin_lock_irqsave(&common
->irqlock
, flags
);
176 /* Initialize field_id */
180 if (vpif_config_data
->set_clock
) {
181 ret
= vpif_config_data
->set_clock(ch
->vpifparams
.std_info
.
182 ycmux_mode
, ch
->vpifparams
.std_info
.hd_sd
);
184 vpif_err("can't set clock\n");
189 /* set the parameters and addresses */
190 ret
= vpif_set_video_params(vpif
, ch
->channel_id
+ 2);
195 vpif_config_addr(ch
, ret
);
196 /* Get the next frame from the buffer queue */
197 common
->next_frm
= common
->cur_frm
=
198 list_entry(common
->dma_queue
.next
,
199 struct vpif_disp_buffer
, list
);
201 list_del(&common
->cur_frm
->list
);
202 spin_unlock_irqrestore(&common
->irqlock
, flags
);
204 addr
= vb2_dma_contig_plane_dma_addr(&common
->cur_frm
->vb
.vb2_buf
, 0);
205 common
->set_addr((addr
+ common
->ytop_off
),
206 (addr
+ common
->ybtm_off
),
207 (addr
+ common
->ctop_off
),
208 (addr
+ common
->cbtm_off
));
211 * Set interrupt for both the fields in VPIF
212 * Register enable channel in VPIF register
214 channel_first_int
[VPIF_VIDEO_INDEX
][ch
->channel_id
] = 1;
215 if (VPIF_CHANNEL2_VIDEO
== ch
->channel_id
) {
216 channel2_intr_assert();
217 channel2_intr_enable(1);
219 if (vpif_config_data
->chan_config
[VPIF_CHANNEL2_VIDEO
].clip_en
)
220 channel2_clipping_enable(1);
223 if (VPIF_CHANNEL3_VIDEO
== ch
->channel_id
|| ycmux_mode
== 2) {
224 channel3_intr_assert();
225 channel3_intr_enable(1);
227 if (vpif_config_data
->chan_config
[VPIF_CHANNEL3_VIDEO
].clip_en
)
228 channel3_clipping_enable(1);
234 list_for_each_entry_safe(buf
, tmp
, &common
->dma_queue
, list
) {
235 list_del(&buf
->list
);
236 vb2_buffer_done(&buf
->vb
.vb2_buf
, VB2_BUF_STATE_QUEUED
);
238 spin_unlock_irqrestore(&common
->irqlock
, flags
);
244 * vpif_stop_streaming : Stop the DMA engine
245 * @vq: ptr to vb2_queue
247 * This callback stops the DMA engine and any remaining buffers
248 * in the DMA queue are released.
250 static void vpif_stop_streaming(struct vb2_queue
*vq
)
252 struct channel_obj
*ch
= vb2_get_drv_priv(vq
);
253 struct common_obj
*common
;
256 common
= &ch
->common
[VPIF_VIDEO_INDEX
];
258 /* Disable channel */
259 if (VPIF_CHANNEL2_VIDEO
== ch
->channel_id
) {
261 channel2_intr_enable(0);
263 if (VPIF_CHANNEL3_VIDEO
== ch
->channel_id
|| ycmux_mode
== 2) {
265 channel3_intr_enable(0);
268 /* release all active buffers */
269 spin_lock_irqsave(&common
->irqlock
, flags
);
270 if (common
->cur_frm
== common
->next_frm
) {
271 vb2_buffer_done(&common
->cur_frm
->vb
.vb2_buf
,
272 VB2_BUF_STATE_ERROR
);
275 vb2_buffer_done(&common
->cur_frm
->vb
.vb2_buf
,
276 VB2_BUF_STATE_ERROR
);
277 if (common
->next_frm
)
278 vb2_buffer_done(&common
->next_frm
->vb
.vb2_buf
,
279 VB2_BUF_STATE_ERROR
);
282 while (!list_empty(&common
->dma_queue
)) {
283 common
->next_frm
= list_entry(common
->dma_queue
.next
,
284 struct vpif_disp_buffer
, list
);
285 list_del(&common
->next_frm
->list
);
286 vb2_buffer_done(&common
->next_frm
->vb
.vb2_buf
,
287 VB2_BUF_STATE_ERROR
);
289 spin_unlock_irqrestore(&common
->irqlock
, flags
);
292 static struct vb2_ops video_qops
= {
293 .queue_setup
= vpif_buffer_queue_setup
,
294 .wait_prepare
= vb2_ops_wait_prepare
,
295 .wait_finish
= vb2_ops_wait_finish
,
296 .buf_prepare
= vpif_buffer_prepare
,
297 .start_streaming
= vpif_start_streaming
,
298 .stop_streaming
= vpif_stop_streaming
,
299 .buf_queue
= vpif_buffer_queue
,
302 static void process_progressive_mode(struct common_obj
*common
)
306 spin_lock(&common
->irqlock
);
307 /* Get the next buffer from buffer queue */
308 common
->next_frm
= list_entry(common
->dma_queue
.next
,
309 struct vpif_disp_buffer
, list
);
310 /* Remove that buffer from the buffer queue */
311 list_del(&common
->next_frm
->list
);
312 spin_unlock(&common
->irqlock
);
314 /* Set top and bottom field addrs in VPIF registers */
315 addr
= vb2_dma_contig_plane_dma_addr(&common
->next_frm
->vb
.vb2_buf
, 0);
316 common
->set_addr(addr
+ common
->ytop_off
,
317 addr
+ common
->ybtm_off
,
318 addr
+ common
->ctop_off
,
319 addr
+ common
->cbtm_off
);
322 static void process_interlaced_mode(int fid
, struct common_obj
*common
)
324 /* device field id and local field id are in sync */
325 /* If this is even field */
327 if (common
->cur_frm
== common
->next_frm
)
330 /* one frame is displayed If next frame is
331 * available, release cur_frm and move on */
332 /* Copy frame display time */
333 common
->cur_frm
->vb
.vb2_buf
.timestamp
= ktime_get_ns();
334 /* Change status of the cur_frm */
335 vb2_buffer_done(&common
->cur_frm
->vb
.vb2_buf
,
337 /* Make cur_frm pointing to next_frm */
338 common
->cur_frm
= common
->next_frm
;
340 } else if (1 == fid
) { /* odd field */
341 spin_lock(&common
->irqlock
);
342 if (list_empty(&common
->dma_queue
)
343 || (common
->cur_frm
!= common
->next_frm
)) {
344 spin_unlock(&common
->irqlock
);
347 spin_unlock(&common
->irqlock
);
348 /* one field is displayed configure the next
349 * frame if it is available else hold on current
351 /* Get next from the buffer queue */
352 process_progressive_mode(common
);
357 * vpif_channel_isr: It changes status of the displayed buffer, takes next
358 * buffer from the queue and sets its address in VPIF registers
360 static irqreturn_t
vpif_channel_isr(int irq
, void *dev_id
)
362 struct vpif_device
*dev
= &vpif_obj
;
363 struct channel_obj
*ch
;
364 struct common_obj
*common
;
368 channel_id
= *(int *)(dev_id
);
369 if (!vpif_intr_status(channel_id
+ 2))
372 ch
= dev
->dev
[channel_id
];
373 for (i
= 0; i
< VPIF_NUMOBJECTS
; i
++) {
374 common
= &ch
->common
[i
];
375 /* If streaming is started in this channel */
377 if (1 == ch
->vpifparams
.std_info
.frm_fmt
) {
378 spin_lock(&common
->irqlock
);
379 if (list_empty(&common
->dma_queue
)) {
380 spin_unlock(&common
->irqlock
);
383 spin_unlock(&common
->irqlock
);
385 /* Progressive mode */
386 if (!channel_first_int
[i
][channel_id
]) {
387 /* Mark status of the cur_frm to
388 * done and unlock semaphore on it */
389 common
->cur_frm
->vb
.vb2_buf
.timestamp
=
391 vb2_buffer_done(&common
->cur_frm
->vb
.vb2_buf
,
393 /* Make cur_frm pointing to next_frm */
394 common
->cur_frm
= common
->next_frm
;
397 channel_first_int
[i
][channel_id
] = 0;
398 process_progressive_mode(common
);
400 /* Interlaced mode */
401 /* If it is first interrupt, ignore it */
403 if (channel_first_int
[i
][channel_id
]) {
404 channel_first_int
[i
][channel_id
] = 0;
410 /* Get field id from VPIF registers */
411 fid
= vpif_channel_getfid(ch
->channel_id
+ 2);
412 /* If fid does not match with stored field id */
413 if (fid
!= ch
->field_id
) {
414 /* Make them in sync */
421 process_interlaced_mode(fid
, common
);
428 static int vpif_update_std_info(struct channel_obj
*ch
)
430 struct video_obj
*vid_ch
= &ch
->video
;
431 struct vpif_params
*vpifparams
= &ch
->vpifparams
;
432 struct vpif_channel_config_params
*std_info
= &vpifparams
->std_info
;
433 const struct vpif_channel_config_params
*config
;
437 for (i
= 0; i
< vpif_ch_params_count
; i
++) {
438 config
= &vpif_ch_params
[i
];
439 if (config
->hd_sd
== 0) {
440 vpif_dbg(2, debug
, "SD format\n");
441 if (config
->stdid
& vid_ch
->stdid
) {
442 memcpy(std_info
, config
, sizeof(*config
));
448 if (i
== vpif_ch_params_count
) {
449 vpif_dbg(1, debug
, "Format not found\n");
456 static int vpif_update_resolution(struct channel_obj
*ch
)
458 struct common_obj
*common
= &ch
->common
[VPIF_VIDEO_INDEX
];
459 struct video_obj
*vid_ch
= &ch
->video
;
460 struct vpif_params
*vpifparams
= &ch
->vpifparams
;
461 struct vpif_channel_config_params
*std_info
= &vpifparams
->std_info
;
463 if (!vid_ch
->stdid
&& !vid_ch
->dv_timings
.bt
.height
)
467 if (vpif_update_std_info(ch
))
471 common
->fmt
.fmt
.pix
.pixelformat
= V4L2_PIX_FMT_YUV422P
;
472 common
->fmt
.fmt
.pix
.width
= std_info
->width
;
473 common
->fmt
.fmt
.pix
.height
= std_info
->height
;
474 vpif_dbg(1, debug
, "Pixel details: Width = %d,Height = %d\n",
475 common
->fmt
.fmt
.pix
.width
, common
->fmt
.fmt
.pix
.height
);
477 /* Set height and width paramateres */
478 common
->height
= std_info
->height
;
479 common
->width
= std_info
->width
;
480 common
->fmt
.fmt
.pix
.sizeimage
= common
->height
* common
->width
* 2;
483 common
->fmt
.fmt
.pix
.colorspace
= V4L2_COLORSPACE_SMPTE170M
;
485 common
->fmt
.fmt
.pix
.colorspace
= V4L2_COLORSPACE_REC709
;
487 if (ch
->vpifparams
.std_info
.frm_fmt
)
488 common
->fmt
.fmt
.pix
.field
= V4L2_FIELD_NONE
;
490 common
->fmt
.fmt
.pix
.field
= V4L2_FIELD_INTERLACED
;
496 * vpif_calculate_offsets: This function calculates buffers offset for Y and C
497 * in the top and bottom field
499 static void vpif_calculate_offsets(struct channel_obj
*ch
)
501 struct common_obj
*common
= &ch
->common
[VPIF_VIDEO_INDEX
];
502 struct vpif_params
*vpifparams
= &ch
->vpifparams
;
503 enum v4l2_field field
= common
->fmt
.fmt
.pix
.field
;
504 struct video_obj
*vid_ch
= &ch
->video
;
505 unsigned int hpitch
, sizeimage
;
507 if (V4L2_FIELD_ANY
== common
->fmt
.fmt
.pix
.field
) {
508 if (ch
->vpifparams
.std_info
.frm_fmt
)
509 vid_ch
->buf_field
= V4L2_FIELD_NONE
;
511 vid_ch
->buf_field
= V4L2_FIELD_INTERLACED
;
513 vid_ch
->buf_field
= common
->fmt
.fmt
.pix
.field
;
516 sizeimage
= common
->fmt
.fmt
.pix
.sizeimage
;
518 hpitch
= common
->fmt
.fmt
.pix
.bytesperline
;
519 if ((V4L2_FIELD_NONE
== vid_ch
->buf_field
) ||
520 (V4L2_FIELD_INTERLACED
== vid_ch
->buf_field
)) {
521 common
->ytop_off
= 0;
522 common
->ybtm_off
= hpitch
;
523 common
->ctop_off
= sizeimage
/ 2;
524 common
->cbtm_off
= sizeimage
/ 2 + hpitch
;
525 } else if (V4L2_FIELD_SEQ_TB
== vid_ch
->buf_field
) {
526 common
->ytop_off
= 0;
527 common
->ybtm_off
= sizeimage
/ 4;
528 common
->ctop_off
= sizeimage
/ 2;
529 common
->cbtm_off
= common
->ctop_off
+ sizeimage
/ 4;
530 } else if (V4L2_FIELD_SEQ_BT
== vid_ch
->buf_field
) {
531 common
->ybtm_off
= 0;
532 common
->ytop_off
= sizeimage
/ 4;
533 common
->cbtm_off
= sizeimage
/ 2;
534 common
->ctop_off
= common
->cbtm_off
+ sizeimage
/ 4;
537 if ((V4L2_FIELD_NONE
== vid_ch
->buf_field
) ||
538 (V4L2_FIELD_INTERLACED
== vid_ch
->buf_field
)) {
539 vpifparams
->video_params
.storage_mode
= 1;
541 vpifparams
->video_params
.storage_mode
= 0;
544 if (ch
->vpifparams
.std_info
.frm_fmt
== 1) {
545 vpifparams
->video_params
.hpitch
=
546 common
->fmt
.fmt
.pix
.bytesperline
;
548 if ((field
== V4L2_FIELD_ANY
) ||
549 (field
== V4L2_FIELD_INTERLACED
))
550 vpifparams
->video_params
.hpitch
=
551 common
->fmt
.fmt
.pix
.bytesperline
* 2;
553 vpifparams
->video_params
.hpitch
=
554 common
->fmt
.fmt
.pix
.bytesperline
;
557 ch
->vpifparams
.video_params
.stdid
= ch
->vpifparams
.std_info
.stdid
;
560 static void vpif_config_addr(struct channel_obj
*ch
, int muxmode
)
562 struct common_obj
*common
= &ch
->common
[VPIF_VIDEO_INDEX
];
564 if (VPIF_CHANNEL3_VIDEO
== ch
->channel_id
) {
565 common
->set_addr
= ch3_set_videobuf_addr
;
568 common
->set_addr
= ch2_set_videobuf_addr_yc_nmux
;
570 common
->set_addr
= ch2_set_videobuf_addr
;
574 /* functions implementing ioctls */
576 * vpif_querycap() - QUERYCAP handler
579 * @cap: ptr to v4l2_capability structure
581 static int vpif_querycap(struct file
*file
, void *priv
,
582 struct v4l2_capability
*cap
)
584 struct vpif_display_config
*config
= vpif_dev
->platform_data
;
586 cap
->device_caps
= V4L2_CAP_VIDEO_OUTPUT
| V4L2_CAP_STREAMING
;
587 cap
->capabilities
= cap
->device_caps
| V4L2_CAP_DEVICE_CAPS
;
588 strlcpy(cap
->driver
, VPIF_DRIVER_NAME
, sizeof(cap
->driver
));
589 snprintf(cap
->bus_info
, sizeof(cap
->bus_info
), "platform:%s",
591 strlcpy(cap
->card
, config
->card_name
, sizeof(cap
->card
));
596 static int vpif_enum_fmt_vid_out(struct file
*file
, void *priv
,
597 struct v4l2_fmtdesc
*fmt
)
602 /* Fill in the information about format */
603 fmt
->type
= V4L2_BUF_TYPE_VIDEO_OUTPUT
;
604 strcpy(fmt
->description
, "YCbCr4:2:2 YC Planar");
605 fmt
->pixelformat
= V4L2_PIX_FMT_YUV422P
;
610 static int vpif_g_fmt_vid_out(struct file
*file
, void *priv
,
611 struct v4l2_format
*fmt
)
613 struct video_device
*vdev
= video_devdata(file
);
614 struct channel_obj
*ch
= video_get_drvdata(vdev
);
615 struct common_obj
*common
= &ch
->common
[VPIF_VIDEO_INDEX
];
617 /* Check the validity of the buffer type */
618 if (common
->fmt
.type
!= fmt
->type
)
621 if (vpif_update_resolution(ch
))
627 static int vpif_try_fmt_vid_out(struct file
*file
, void *priv
,
628 struct v4l2_format
*fmt
)
630 struct video_device
*vdev
= video_devdata(file
);
631 struct channel_obj
*ch
= video_get_drvdata(vdev
);
632 struct common_obj
*common
= &ch
->common
[VPIF_VIDEO_INDEX
];
633 struct v4l2_pix_format
*pixfmt
= &fmt
->fmt
.pix
;
636 * to supress v4l-compliance warnings silently correct
639 if (pixfmt
->pixelformat
!= V4L2_PIX_FMT_YUV422P
)
640 pixfmt
->pixelformat
= common
->fmt
.fmt
.pix
.pixelformat
;
642 if (vpif_update_resolution(ch
))
645 pixfmt
->colorspace
= common
->fmt
.fmt
.pix
.colorspace
;
646 pixfmt
->field
= common
->fmt
.fmt
.pix
.field
;
647 pixfmt
->bytesperline
= common
->fmt
.fmt
.pix
.width
;
648 pixfmt
->width
= common
->fmt
.fmt
.pix
.width
;
649 pixfmt
->height
= common
->fmt
.fmt
.pix
.height
;
650 pixfmt
->sizeimage
= pixfmt
->bytesperline
* pixfmt
->height
* 2;
655 static int vpif_s_fmt_vid_out(struct file
*file
, void *priv
,
656 struct v4l2_format
*fmt
)
658 struct video_device
*vdev
= video_devdata(file
);
659 struct channel_obj
*ch
= video_get_drvdata(vdev
);
660 struct common_obj
*common
= &ch
->common
[VPIF_VIDEO_INDEX
];
661 struct v4l2_pix_format
*pixfmt
= &fmt
->fmt
.pix
;
664 if (vb2_is_busy(&common
->buffer_queue
))
667 ret
= vpif_try_fmt_vid_out(file
, priv
, fmt
);
671 /* store the pix format in the channel object */
672 common
->fmt
.fmt
.pix
= *pixfmt
;
674 /* store the format in the channel object */
679 static int vpif_s_std(struct file
*file
, void *priv
, v4l2_std_id std_id
)
681 struct vpif_display_config
*config
= vpif_dev
->platform_data
;
682 struct video_device
*vdev
= video_devdata(file
);
683 struct channel_obj
*ch
= video_get_drvdata(vdev
);
684 struct common_obj
*common
= &ch
->common
[VPIF_VIDEO_INDEX
];
685 struct vpif_display_chan_config
*chan_cfg
;
686 struct v4l2_output output
;
689 if (!config
->chan_config
[ch
->channel_id
].outputs
)
692 chan_cfg
= &config
->chan_config
[ch
->channel_id
];
693 output
= chan_cfg
->outputs
[ch
->output_idx
].output
;
694 if (output
.capabilities
!= V4L2_OUT_CAP_STD
)
697 if (vb2_is_busy(&common
->buffer_queue
))
701 if (!(std_id
& VPIF_V4L2_STD
))
704 /* Call encoder subdevice function to set the standard */
705 ch
->video
.stdid
= std_id
;
706 memset(&ch
->video
.dv_timings
, 0, sizeof(ch
->video
.dv_timings
));
707 /* Get the information about the standard */
708 if (vpif_update_resolution(ch
))
711 common
->fmt
.fmt
.pix
.bytesperline
= common
->fmt
.fmt
.pix
.width
;
713 ret
= v4l2_device_call_until_err(&vpif_obj
.v4l2_dev
, 1, video
,
714 s_std_output
, std_id
);
716 vpif_err("Failed to set output standard\n");
720 ret
= v4l2_device_call_until_err(&vpif_obj
.v4l2_dev
, 1, video
,
723 vpif_err("Failed to set standard for sub devices\n");
727 static int vpif_g_std(struct file
*file
, void *priv
, v4l2_std_id
*std
)
729 struct vpif_display_config
*config
= vpif_dev
->platform_data
;
730 struct video_device
*vdev
= video_devdata(file
);
731 struct channel_obj
*ch
= video_get_drvdata(vdev
);
732 struct vpif_display_chan_config
*chan_cfg
;
733 struct v4l2_output output
;
735 if (!config
->chan_config
[ch
->channel_id
].outputs
)
738 chan_cfg
= &config
->chan_config
[ch
->channel_id
];
739 output
= chan_cfg
->outputs
[ch
->output_idx
].output
;
740 if (output
.capabilities
!= V4L2_OUT_CAP_STD
)
743 *std
= ch
->video
.stdid
;
747 static int vpif_enum_output(struct file
*file
, void *fh
,
748 struct v4l2_output
*output
)
751 struct vpif_display_config
*config
= vpif_dev
->platform_data
;
752 struct video_device
*vdev
= video_devdata(file
);
753 struct channel_obj
*ch
= video_get_drvdata(vdev
);
754 struct vpif_display_chan_config
*chan_cfg
;
756 chan_cfg
= &config
->chan_config
[ch
->channel_id
];
757 if (output
->index
>= chan_cfg
->output_count
) {
758 vpif_dbg(1, debug
, "Invalid output index\n");
762 *output
= chan_cfg
->outputs
[output
->index
].output
;
767 * vpif_output_to_subdev() - Maps output to sub device
768 * @vpif_cfg - global config ptr
769 * @chan_cfg - channel config ptr
770 * @index - Given output index from application
772 * lookup the sub device information for a given output index.
773 * we report all the output to application. output table also
774 * has sub device name for the each output
777 vpif_output_to_subdev(struct vpif_display_config
*vpif_cfg
,
778 struct vpif_display_chan_config
*chan_cfg
, int index
)
780 struct vpif_subdev_info
*subdev_info
;
781 const char *subdev_name
;
784 vpif_dbg(2, debug
, "vpif_output_to_subdev\n");
786 if (!chan_cfg
->outputs
)
789 subdev_name
= chan_cfg
->outputs
[index
].subdev_name
;
793 /* loop through the sub device list to get the sub device info */
794 for (i
= 0; i
< vpif_cfg
->subdev_count
; i
++) {
795 subdev_info
= &vpif_cfg
->subdevinfo
[i
];
796 if (!strcmp(subdev_info
->name
, subdev_name
))
803 * vpif_set_output() - Select an output
804 * @vpif_cfg - global config ptr
806 * @index - Given output index from application
808 * Select the given output.
810 static int vpif_set_output(struct vpif_display_config
*vpif_cfg
,
811 struct channel_obj
*ch
, int index
)
813 struct vpif_display_chan_config
*chan_cfg
=
814 &vpif_cfg
->chan_config
[ch
->channel_id
];
815 struct v4l2_subdev
*sd
= NULL
;
816 u32 input
= 0, output
= 0;
820 sd_index
= vpif_output_to_subdev(vpif_cfg
, chan_cfg
, index
);
822 sd
= vpif_obj
.sd
[sd_index
];
825 input
= chan_cfg
->outputs
[index
].input_route
;
826 output
= chan_cfg
->outputs
[index
].output_route
;
827 ret
= v4l2_subdev_call(sd
, video
, s_routing
, input
, output
, 0);
828 if (ret
< 0 && ret
!= -ENOIOCTLCMD
) {
829 vpif_err("Failed to set output\n");
834 ch
->output_idx
= index
;
836 if (chan_cfg
->outputs
)
837 /* update tvnorms from the sub device output info */
838 ch
->video_dev
.tvnorms
= chan_cfg
->outputs
[index
].output
.std
;
842 static int vpif_s_output(struct file
*file
, void *priv
, unsigned int i
)
844 struct vpif_display_config
*config
= vpif_dev
->platform_data
;
845 struct video_device
*vdev
= video_devdata(file
);
846 struct channel_obj
*ch
= video_get_drvdata(vdev
);
847 struct vpif_display_chan_config
*chan_cfg
;
848 struct common_obj
*common
= &ch
->common
[VPIF_VIDEO_INDEX
];
850 if (vb2_is_busy(&common
->buffer_queue
))
853 chan_cfg
= &config
->chan_config
[ch
->channel_id
];
855 if (i
>= chan_cfg
->output_count
)
858 return vpif_set_output(config
, ch
, i
);
861 static int vpif_g_output(struct file
*file
, void *priv
, unsigned int *i
)
863 struct video_device
*vdev
= video_devdata(file
);
864 struct channel_obj
*ch
= video_get_drvdata(vdev
);
872 * vpif_enum_dv_timings() - ENUM_DV_TIMINGS handler
875 * @timings: input timings
878 vpif_enum_dv_timings(struct file
*file
, void *priv
,
879 struct v4l2_enum_dv_timings
*timings
)
881 struct vpif_display_config
*config
= vpif_dev
->platform_data
;
882 struct video_device
*vdev
= video_devdata(file
);
883 struct channel_obj
*ch
= video_get_drvdata(vdev
);
884 struct vpif_display_chan_config
*chan_cfg
;
885 struct v4l2_output output
;
888 if (!config
->chan_config
[ch
->channel_id
].outputs
)
891 chan_cfg
= &config
->chan_config
[ch
->channel_id
];
892 output
= chan_cfg
->outputs
[ch
->output_idx
].output
;
893 if (output
.capabilities
!= V4L2_OUT_CAP_DV_TIMINGS
)
898 ret
= v4l2_subdev_call(ch
->sd
, pad
, enum_dv_timings
, timings
);
899 if (ret
== -ENOIOCTLCMD
|| ret
== -ENODEV
)
905 * vpif_s_dv_timings() - S_DV_TIMINGS handler
908 * @timings: digital video timings
910 static int vpif_s_dv_timings(struct file
*file
, void *priv
,
911 struct v4l2_dv_timings
*timings
)
913 struct vpif_display_config
*config
= vpif_dev
->platform_data
;
914 struct video_device
*vdev
= video_devdata(file
);
915 struct channel_obj
*ch
= video_get_drvdata(vdev
);
916 struct vpif_params
*vpifparams
= &ch
->vpifparams
;
917 struct common_obj
*common
= &ch
->common
[VPIF_VIDEO_INDEX
];
918 struct vpif_channel_config_params
*std_info
= &vpifparams
->std_info
;
919 struct video_obj
*vid_ch
= &ch
->video
;
920 struct v4l2_bt_timings
*bt
= &vid_ch
->dv_timings
.bt
;
921 struct vpif_display_chan_config
*chan_cfg
;
922 struct v4l2_output output
;
925 if (!config
->chan_config
[ch
->channel_id
].outputs
)
928 chan_cfg
= &config
->chan_config
[ch
->channel_id
];
929 output
= chan_cfg
->outputs
[ch
->output_idx
].output
;
930 if (output
.capabilities
!= V4L2_OUT_CAP_DV_TIMINGS
)
933 if (vb2_is_busy(&common
->buffer_queue
))
936 if (timings
->type
!= V4L2_DV_BT_656_1120
) {
937 vpif_dbg(2, debug
, "Timing type not defined\n");
941 /* Configure subdevice timings, if any */
942 ret
= v4l2_subdev_call(ch
->sd
, video
, s_dv_timings
, timings
);
943 if (ret
== -ENOIOCTLCMD
|| ret
== -ENODEV
)
946 vpif_dbg(2, debug
, "Error setting custom DV timings\n");
950 if (!(timings
->bt
.width
&& timings
->bt
.height
&&
951 (timings
->bt
.hbackporch
||
952 timings
->bt
.hfrontporch
||
953 timings
->bt
.hsync
) &&
954 timings
->bt
.vfrontporch
&&
955 (timings
->bt
.vbackporch
||
956 timings
->bt
.vsync
))) {
957 vpif_dbg(2, debug
, "Timings for width, height, horizontal back porch, horizontal sync, horizontal front porch, vertical back porch, vertical sync and vertical back porch must be defined\n");
961 vid_ch
->dv_timings
= *timings
;
963 /* Configure video port timings */
965 std_info
->eav2sav
= V4L2_DV_BT_BLANKING_WIDTH(bt
) - 8;
966 std_info
->sav2eav
= bt
->width
;
969 std_info
->l3
= bt
->vsync
+ bt
->vbackporch
+ 1;
971 std_info
->vsize
= V4L2_DV_BT_FRAME_HEIGHT(bt
);
972 if (bt
->interlaced
) {
973 if (bt
->il_vbackporch
|| bt
->il_vfrontporch
|| bt
->il_vsync
) {
974 std_info
->l5
= std_info
->vsize
/2 -
975 (bt
->vfrontporch
- 1);
976 std_info
->l7
= std_info
->vsize
/2 + 1;
977 std_info
->l9
= std_info
->l7
+ bt
->il_vsync
+
978 bt
->il_vbackporch
+ 1;
979 std_info
->l11
= std_info
->vsize
-
980 (bt
->il_vfrontporch
- 1);
982 vpif_dbg(2, debug
, "Required timing values for interlaced BT format missing\n");
986 std_info
->l5
= std_info
->vsize
- (bt
->vfrontporch
- 1);
988 strncpy(std_info
->name
, "Custom timings BT656/1120",
990 std_info
->width
= bt
->width
;
991 std_info
->height
= bt
->height
;
992 std_info
->frm_fmt
= bt
->interlaced
? 0 : 1;
993 std_info
->ycmux_mode
= 0;
994 std_info
->capture_format
= 0;
995 std_info
->vbi_supported
= 0;
1004 * vpif_g_dv_timings() - G_DV_TIMINGS handler
1006 * @priv: file handle
1007 * @timings: digital video timings
1009 static int vpif_g_dv_timings(struct file
*file
, void *priv
,
1010 struct v4l2_dv_timings
*timings
)
1012 struct vpif_display_config
*config
= vpif_dev
->platform_data
;
1013 struct video_device
*vdev
= video_devdata(file
);
1014 struct channel_obj
*ch
= video_get_drvdata(vdev
);
1015 struct vpif_display_chan_config
*chan_cfg
;
1016 struct video_obj
*vid_ch
= &ch
->video
;
1017 struct v4l2_output output
;
1019 if (!config
->chan_config
[ch
->channel_id
].outputs
)
1022 chan_cfg
= &config
->chan_config
[ch
->channel_id
];
1023 output
= chan_cfg
->outputs
[ch
->output_idx
].output
;
1025 if (output
.capabilities
!= V4L2_OUT_CAP_DV_TIMINGS
)
1028 *timings
= vid_ch
->dv_timings
;
1036 * vpif_log_status() - Status information
1038 * @priv: file handle
1042 static int vpif_log_status(struct file
*filep
, void *priv
)
1044 /* status for sub devices */
1045 v4l2_device_call_all(&vpif_obj
.v4l2_dev
, 0, core
, log_status
);
1050 /* vpif display ioctl operations */
1051 static const struct v4l2_ioctl_ops vpif_ioctl_ops
= {
1052 .vidioc_querycap
= vpif_querycap
,
1053 .vidioc_enum_fmt_vid_out
= vpif_enum_fmt_vid_out
,
1054 .vidioc_g_fmt_vid_out
= vpif_g_fmt_vid_out
,
1055 .vidioc_s_fmt_vid_out
= vpif_s_fmt_vid_out
,
1056 .vidioc_try_fmt_vid_out
= vpif_try_fmt_vid_out
,
1058 .vidioc_reqbufs
= vb2_ioctl_reqbufs
,
1059 .vidioc_create_bufs
= vb2_ioctl_create_bufs
,
1060 .vidioc_querybuf
= vb2_ioctl_querybuf
,
1061 .vidioc_qbuf
= vb2_ioctl_qbuf
,
1062 .vidioc_dqbuf
= vb2_ioctl_dqbuf
,
1063 .vidioc_expbuf
= vb2_ioctl_expbuf
,
1064 .vidioc_streamon
= vb2_ioctl_streamon
,
1065 .vidioc_streamoff
= vb2_ioctl_streamoff
,
1067 .vidioc_s_std
= vpif_s_std
,
1068 .vidioc_g_std
= vpif_g_std
,
1070 .vidioc_enum_output
= vpif_enum_output
,
1071 .vidioc_s_output
= vpif_s_output
,
1072 .vidioc_g_output
= vpif_g_output
,
1074 .vidioc_enum_dv_timings
= vpif_enum_dv_timings
,
1075 .vidioc_s_dv_timings
= vpif_s_dv_timings
,
1076 .vidioc_g_dv_timings
= vpif_g_dv_timings
,
1078 .vidioc_log_status
= vpif_log_status
,
1081 static const struct v4l2_file_operations vpif_fops
= {
1082 .owner
= THIS_MODULE
,
1083 .open
= v4l2_fh_open
,
1084 .release
= vb2_fop_release
,
1085 .unlocked_ioctl
= video_ioctl2
,
1086 .mmap
= vb2_fop_mmap
,
1087 .poll
= vb2_fop_poll
1090 /*Configure the channels, buffer sizei, request irq */
1091 static int initialize_vpif(void)
1093 int free_channel_objects_index
;
1096 /* Allocate memory for six channel objects */
1097 for (i
= 0; i
< VPIF_DISPLAY_MAX_DEVICES
; i
++) {
1099 kzalloc(sizeof(struct channel_obj
), GFP_KERNEL
);
1100 /* If memory allocation fails, return error */
1101 if (!vpif_obj
.dev
[i
]) {
1102 free_channel_objects_index
= i
;
1104 goto vpif_init_free_channel_objects
;
1110 vpif_init_free_channel_objects
:
1111 for (j
= 0; j
< free_channel_objects_index
; j
++)
1112 kfree(vpif_obj
.dev
[j
]);
1116 static int vpif_async_bound(struct v4l2_async_notifier
*notifier
,
1117 struct v4l2_subdev
*subdev
,
1118 struct v4l2_async_subdev
*asd
)
1122 for (i
= 0; i
< vpif_obj
.config
->subdev_count
; i
++)
1123 if (!strcmp(vpif_obj
.config
->subdevinfo
[i
].name
,
1125 vpif_obj
.sd
[i
] = subdev
;
1126 vpif_obj
.sd
[i
]->grp_id
= 1 << i
;
1133 static int vpif_probe_complete(void)
1135 struct common_obj
*common
;
1136 struct video_device
*vdev
;
1137 struct channel_obj
*ch
;
1138 struct vb2_queue
*q
;
1141 for (j
= 0; j
< VPIF_DISPLAY_MAX_DEVICES
; j
++) {
1142 ch
= vpif_obj
.dev
[j
];
1143 /* Initialize field of the channel objects */
1144 for (k
= 0; k
< VPIF_NUMOBJECTS
; k
++) {
1145 common
= &ch
->common
[k
];
1146 spin_lock_init(&common
->irqlock
);
1147 mutex_init(&common
->lock
);
1148 common
->set_addr
= NULL
;
1149 common
->ytop_off
= 0;
1150 common
->ybtm_off
= 0;
1151 common
->ctop_off
= 0;
1152 common
->cbtm_off
= 0;
1153 common
->cur_frm
= NULL
;
1154 common
->next_frm
= NULL
;
1155 memset(&common
->fmt
, 0, sizeof(common
->fmt
));
1157 ch
->initialized
= 0;
1158 if (vpif_obj
.config
->subdev_count
)
1159 ch
->sd
= vpif_obj
.sd
[0];
1162 memset(&ch
->vpifparams
, 0, sizeof(ch
->vpifparams
));
1164 ch
->common
[VPIF_VIDEO_INDEX
].fmt
.type
=
1165 V4L2_BUF_TYPE_VIDEO_OUTPUT
;
1167 /* select output 0 */
1168 err
= vpif_set_output(vpif_obj
.config
, ch
, 0);
1172 /* set initial format */
1173 ch
->video
.stdid
= V4L2_STD_525_60
;
1174 memset(&ch
->video
.dv_timings
, 0, sizeof(ch
->video
.dv_timings
));
1175 vpif_update_resolution(ch
);
1177 /* Initialize vb2 queue */
1178 q
= &common
->buffer_queue
;
1179 q
->type
= V4L2_BUF_TYPE_VIDEO_OUTPUT
;
1180 q
->io_modes
= VB2_MMAP
| VB2_USERPTR
| VB2_DMABUF
;
1182 q
->ops
= &video_qops
;
1183 q
->mem_ops
= &vb2_dma_contig_memops
;
1184 q
->buf_struct_size
= sizeof(struct vpif_disp_buffer
);
1185 q
->timestamp_flags
= V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC
;
1186 q
->min_buffers_needed
= 1;
1187 q
->lock
= &common
->lock
;
1189 err
= vb2_queue_init(q
);
1191 vpif_err("vpif_display: vb2_queue_init() failed\n");
1195 INIT_LIST_HEAD(&common
->dma_queue
);
1197 /* register video device */
1198 vpif_dbg(1, debug
, "channel=%p,channel->video_dev=%p\n",
1199 ch
, &ch
->video_dev
);
1201 /* Initialize the video_device structure */
1202 vdev
= &ch
->video_dev
;
1203 strlcpy(vdev
->name
, VPIF_DRIVER_NAME
, sizeof(vdev
->name
));
1204 vdev
->release
= video_device_release_empty
;
1205 vdev
->fops
= &vpif_fops
;
1206 vdev
->ioctl_ops
= &vpif_ioctl_ops
;
1207 vdev
->v4l2_dev
= &vpif_obj
.v4l2_dev
;
1208 vdev
->vfl_dir
= VFL_DIR_TX
;
1210 vdev
->lock
= &common
->lock
;
1211 video_set_drvdata(&ch
->video_dev
, ch
);
1212 err
= video_register_device(vdev
, VFL_TYPE_GRABBER
,
1221 for (k
= 0; k
< j
; k
++) {
1222 ch
= vpif_obj
.dev
[k
];
1223 common
= &ch
->common
[k
];
1224 video_unregister_device(&ch
->video_dev
);
1229 static int vpif_async_complete(struct v4l2_async_notifier
*notifier
)
1231 return vpif_probe_complete();
1235 * vpif_probe: This function creates device entries by register itself to the
1236 * V4L2 driver and initializes fields of each channel objects
1238 static __init
int vpif_probe(struct platform_device
*pdev
)
1240 struct vpif_subdev_info
*subdevdata
;
1241 struct i2c_adapter
*i2c_adap
;
1242 struct resource
*res
;
1247 vpif_dev
= &pdev
->dev
;
1248 err
= initialize_vpif();
1251 v4l2_err(vpif_dev
->driver
, "Error initializing vpif\n");
1255 err
= v4l2_device_register(vpif_dev
, &vpif_obj
.v4l2_dev
);
1257 v4l2_err(vpif_dev
->driver
, "Error registering v4l2 device\n");
1261 while ((res
= platform_get_resource(pdev
, IORESOURCE_IRQ
, res_idx
))) {
1262 err
= devm_request_irq(&pdev
->dev
, res
->start
, vpif_channel_isr
,
1263 IRQF_SHARED
, VPIF_DRIVER_NAME
,
1264 (void *)(&vpif_obj
.dev
[res_idx
]->
1268 vpif_err("VPIF IRQ request failed\n");
1269 goto vpif_unregister
;
1274 vpif_obj
.config
= pdev
->dev
.platform_data
;
1275 subdev_count
= vpif_obj
.config
->subdev_count
;
1276 subdevdata
= vpif_obj
.config
->subdevinfo
;
1277 vpif_obj
.sd
= kcalloc(subdev_count
, sizeof(*vpif_obj
.sd
), GFP_KERNEL
);
1280 goto vpif_unregister
;
1283 if (!vpif_obj
.config
->asd_sizes
) {
1284 i2c_adap
= i2c_get_adapter(1);
1285 for (i
= 0; i
< subdev_count
; i
++) {
1287 v4l2_i2c_new_subdev_board(&vpif_obj
.v4l2_dev
,
1292 if (!vpif_obj
.sd
[i
]) {
1293 vpif_err("Error registering v4l2 subdevice\n");
1295 goto probe_subdev_out
;
1299 vpif_obj
.sd
[i
]->grp_id
= 1 << i
;
1301 vpif_probe_complete();
1303 vpif_obj
.notifier
.subdevs
= vpif_obj
.config
->asd
;
1304 vpif_obj
.notifier
.num_subdevs
= vpif_obj
.config
->asd_sizes
[0];
1305 vpif_obj
.notifier
.bound
= vpif_async_bound
;
1306 vpif_obj
.notifier
.complete
= vpif_async_complete
;
1307 err
= v4l2_async_notifier_register(&vpif_obj
.v4l2_dev
,
1308 &vpif_obj
.notifier
);
1310 vpif_err("Error registering async notifier\n");
1312 goto probe_subdev_out
;
1321 v4l2_device_unregister(&vpif_obj
.v4l2_dev
);
1327 * vpif_remove: It un-register channels from V4L2 driver
1329 static int vpif_remove(struct platform_device
*device
)
1331 struct common_obj
*common
;
1332 struct channel_obj
*ch
;
1335 v4l2_device_unregister(&vpif_obj
.v4l2_dev
);
1338 /* un-register device */
1339 for (i
= 0; i
< VPIF_DISPLAY_MAX_DEVICES
; i
++) {
1340 /* Get the pointer to the channel object */
1341 ch
= vpif_obj
.dev
[i
];
1342 common
= &ch
->common
[VPIF_VIDEO_INDEX
];
1343 /* Unregister video device */
1344 video_unregister_device(&ch
->video_dev
);
1345 kfree(vpif_obj
.dev
[i
]);
1351 #ifdef CONFIG_PM_SLEEP
1352 static int vpif_suspend(struct device
*dev
)
1354 struct common_obj
*common
;
1355 struct channel_obj
*ch
;
1358 for (i
= 0; i
< VPIF_DISPLAY_MAX_DEVICES
; i
++) {
1359 /* Get the pointer to the channel object */
1360 ch
= vpif_obj
.dev
[i
];
1361 common
= &ch
->common
[VPIF_VIDEO_INDEX
];
1363 if (!vb2_start_streaming_called(&common
->buffer_queue
))
1366 mutex_lock(&common
->lock
);
1367 /* Disable channel */
1368 if (ch
->channel_id
== VPIF_CHANNEL2_VIDEO
) {
1370 channel2_intr_enable(0);
1372 if (ch
->channel_id
== VPIF_CHANNEL3_VIDEO
||
1375 channel3_intr_enable(0);
1377 mutex_unlock(&common
->lock
);
1383 static int vpif_resume(struct device
*dev
)
1386 struct common_obj
*common
;
1387 struct channel_obj
*ch
;
1390 for (i
= 0; i
< VPIF_DISPLAY_MAX_DEVICES
; i
++) {
1391 /* Get the pointer to the channel object */
1392 ch
= vpif_obj
.dev
[i
];
1393 common
= &ch
->common
[VPIF_VIDEO_INDEX
];
1395 if (!vb2_start_streaming_called(&common
->buffer_queue
))
1398 mutex_lock(&common
->lock
);
1399 /* Enable channel */
1400 if (ch
->channel_id
== VPIF_CHANNEL2_VIDEO
) {
1402 channel2_intr_enable(1);
1404 if (ch
->channel_id
== VPIF_CHANNEL3_VIDEO
||
1407 channel3_intr_enable(1);
1409 mutex_unlock(&common
->lock
);
1417 static SIMPLE_DEV_PM_OPS(vpif_pm_ops
, vpif_suspend
, vpif_resume
);
1419 static __refdata
struct platform_driver vpif_driver
= {
1421 .name
= VPIF_DRIVER_NAME
,
1424 .probe
= vpif_probe
,
1425 .remove
= vpif_remove
,
1428 module_platform_driver(vpif_driver
);