2 * TI VPE mem2mem driver, based on the virtual v4l2-mem2mem example driver
4 * Copyright (c) 2013 Texas Instruments Inc.
5 * David Griego, <dagriego@biglakesoftware.com>
6 * Dale Farnsworth, <dale@farnsworth.org>
7 * Archit Taneja, <archit@ti.com>
9 * Copyright (c) 2009-2010 Samsung Electronics Co., Ltd.
10 * Pawel Osciak, <pawel@osciak.com>
11 * Marek Szyprowski, <m.szyprowski@samsung.com>
13 * Based on the virtual v4l2-mem2mem example device
15 * This program is free software; you can redistribute it and/or modify it
16 * under the terms of the GNU General Public License version 2 as published by
17 * the Free Software Foundation
20 #include <linux/delay.h>
21 #include <linux/dma-mapping.h>
22 #include <linux/err.h>
24 #include <linux/interrupt.h>
26 #include <linux/ioctl.h>
27 #include <linux/module.h>
29 #include <linux/platform_device.h>
30 #include <linux/pm_runtime.h>
31 #include <linux/sched.h>
32 #include <linux/slab.h>
33 #include <linux/videodev2.h>
34 #include <linux/log2.h>
35 #include <linux/sizes.h>
37 #include <media/v4l2-common.h>
38 #include <media/v4l2-ctrls.h>
39 #include <media/v4l2-device.h>
40 #include <media/v4l2-event.h>
41 #include <media/v4l2-ioctl.h>
42 #include <media/v4l2-mem2mem.h>
43 #include <media/videobuf2-v4l2.h>
44 #include <media/videobuf2-dma-contig.h>
47 #include "vpdma_priv.h"
52 #define VPE_MODULE_NAME "vpe"
54 /* minimum and maximum frame sizes */
60 /* required alignments */
61 #define S_ALIGN 0 /* multiple of 1 */
62 #define H_ALIGN 1 /* multiple of 2 */
64 /* flags that indicate a format can be used for capture/output */
65 #define VPE_FMT_TYPE_CAPTURE (1 << 0)
66 #define VPE_FMT_TYPE_OUTPUT (1 << 1)
68 /* used as plane indices */
69 #define VPE_MAX_PLANES 2
73 /* per m2m context info */
74 #define VPE_MAX_SRC_BUFS 3 /* need 3 src fields to de-interlace */
76 #define VPE_DEF_BUFS_PER_JOB 1 /* default one buffer per batch job */
79 * each VPE context can need up to 3 config descriptors, 7 input descriptors,
80 * 3 output descriptors, and 10 control descriptors
82 #define VPE_DESC_LIST_SIZE (10 * VPDMA_DTD_DESC_SIZE + \
83 13 * VPDMA_CFD_CTD_DESC_SIZE)
85 #define vpe_dbg(vpedev, fmt, arg...) \
86 dev_dbg((vpedev)->v4l2_dev.dev, fmt, ##arg)
87 #define vpe_err(vpedev, fmt, arg...) \
88 dev_err((vpedev)->v4l2_dev.dev, fmt, ##arg)
90 struct vpe_us_coeffs
{
91 unsigned short anchor_fid0_c0
;
92 unsigned short anchor_fid0_c1
;
93 unsigned short anchor_fid0_c2
;
94 unsigned short anchor_fid0_c3
;
95 unsigned short interp_fid0_c0
;
96 unsigned short interp_fid0_c1
;
97 unsigned short interp_fid0_c2
;
98 unsigned short interp_fid0_c3
;
99 unsigned short anchor_fid1_c0
;
100 unsigned short anchor_fid1_c1
;
101 unsigned short anchor_fid1_c2
;
102 unsigned short anchor_fid1_c3
;
103 unsigned short interp_fid1_c0
;
104 unsigned short interp_fid1_c1
;
105 unsigned short interp_fid1_c2
;
106 unsigned short interp_fid1_c3
;
110 * Default upsampler coefficients
112 static const struct vpe_us_coeffs us_coeffs
[] = {
114 /* Coefficients for progressive input */
115 0x00C8, 0x0348, 0x0018, 0x3FD8, 0x3FB8, 0x0378, 0x00E8, 0x3FE8,
116 0x00C8, 0x0348, 0x0018, 0x3FD8, 0x3FB8, 0x0378, 0x00E8, 0x3FE8,
119 /* Coefficients for Top Field Interlaced input */
120 0x0051, 0x03D5, 0x3FE3, 0x3FF7, 0x3FB5, 0x02E9, 0x018F, 0x3FD3,
121 /* Coefficients for Bottom Field Interlaced input */
122 0x016B, 0x0247, 0x00B1, 0x3F9D, 0x3FCF, 0x03DB, 0x005D, 0x3FF9,
127 * the following registers are for configuring some of the parameters of the
128 * motion and edge detection blocks inside DEI, these generally remain the same,
129 * these could be passed later via userspace if some one needs to tweak these.
131 struct vpe_dei_regs
{
132 unsigned long mdt_spacial_freq_thr_reg
; /* VPE_DEI_REG2 */
133 unsigned long edi_config_reg
; /* VPE_DEI_REG3 */
134 unsigned long edi_lut_reg0
; /* VPE_DEI_REG4 */
135 unsigned long edi_lut_reg1
; /* VPE_DEI_REG5 */
136 unsigned long edi_lut_reg2
; /* VPE_DEI_REG6 */
137 unsigned long edi_lut_reg3
; /* VPE_DEI_REG7 */
141 * default expert DEI register values, unlikely to be modified.
143 static const struct vpe_dei_regs dei_regs
= {
144 .mdt_spacial_freq_thr_reg
= 0x020C0804u
,
145 .edi_config_reg
= 0x0118100Cu
,
146 .edi_lut_reg0
= 0x08040200u
,
147 .edi_lut_reg1
= 0x1010100Cu
,
148 .edi_lut_reg2
= 0x10101010u
,
149 .edi_lut_reg3
= 0x10101010u
,
153 * The port_data structure contains per-port data.
155 struct vpe_port_data
{
156 enum vpdma_channel channel
; /* VPDMA channel */
157 u8 vb_index
; /* input frame f, f-1, f-2 index */
158 u8 vb_part
; /* plane index for co-panar formats */
162 * Define indices into the port_data tables
164 #define VPE_PORT_LUMA1_IN 0
165 #define VPE_PORT_CHROMA1_IN 1
166 #define VPE_PORT_LUMA2_IN 2
167 #define VPE_PORT_CHROMA2_IN 3
168 #define VPE_PORT_LUMA3_IN 4
169 #define VPE_PORT_CHROMA3_IN 5
170 #define VPE_PORT_MV_IN 6
171 #define VPE_PORT_MV_OUT 7
172 #define VPE_PORT_LUMA_OUT 8
173 #define VPE_PORT_CHROMA_OUT 9
174 #define VPE_PORT_RGB_OUT 10
176 static const struct vpe_port_data port_data
[11] = {
177 [VPE_PORT_LUMA1_IN
] = {
178 .channel
= VPE_CHAN_LUMA1_IN
,
182 [VPE_PORT_CHROMA1_IN
] = {
183 .channel
= VPE_CHAN_CHROMA1_IN
,
185 .vb_part
= VPE_CHROMA
,
187 [VPE_PORT_LUMA2_IN
] = {
188 .channel
= VPE_CHAN_LUMA2_IN
,
192 [VPE_PORT_CHROMA2_IN
] = {
193 .channel
= VPE_CHAN_CHROMA2_IN
,
195 .vb_part
= VPE_CHROMA
,
197 [VPE_PORT_LUMA3_IN
] = {
198 .channel
= VPE_CHAN_LUMA3_IN
,
202 [VPE_PORT_CHROMA3_IN
] = {
203 .channel
= VPE_CHAN_CHROMA3_IN
,
205 .vb_part
= VPE_CHROMA
,
208 .channel
= VPE_CHAN_MV_IN
,
210 [VPE_PORT_MV_OUT
] = {
211 .channel
= VPE_CHAN_MV_OUT
,
213 [VPE_PORT_LUMA_OUT
] = {
214 .channel
= VPE_CHAN_LUMA_OUT
,
217 [VPE_PORT_CHROMA_OUT
] = {
218 .channel
= VPE_CHAN_CHROMA_OUT
,
219 .vb_part
= VPE_CHROMA
,
221 [VPE_PORT_RGB_OUT
] = {
222 .channel
= VPE_CHAN_RGB_OUT
,
228 /* driver info for each of the supported video formats */
230 char *name
; /* human-readable name */
231 u32 fourcc
; /* standard format identifier */
232 u8 types
; /* CAPTURE and/or OUTPUT */
233 u8 coplanar
; /* set for unpacked Luma and Chroma */
234 /* vpdma format info for each plane */
235 struct vpdma_data_format
const *vpdma_fmt
[VPE_MAX_PLANES
];
238 static struct vpe_fmt vpe_formats
[] = {
240 .name
= "NV16 YUV 422 co-planar",
241 .fourcc
= V4L2_PIX_FMT_NV16
,
242 .types
= VPE_FMT_TYPE_CAPTURE
| VPE_FMT_TYPE_OUTPUT
,
244 .vpdma_fmt
= { &vpdma_yuv_fmts
[VPDMA_DATA_FMT_Y444
],
245 &vpdma_yuv_fmts
[VPDMA_DATA_FMT_C444
],
249 .name
= "NV12 YUV 420 co-planar",
250 .fourcc
= V4L2_PIX_FMT_NV12
,
251 .types
= VPE_FMT_TYPE_CAPTURE
| VPE_FMT_TYPE_OUTPUT
,
253 .vpdma_fmt
= { &vpdma_yuv_fmts
[VPDMA_DATA_FMT_Y420
],
254 &vpdma_yuv_fmts
[VPDMA_DATA_FMT_C420
],
258 .name
= "YUYV 422 packed",
259 .fourcc
= V4L2_PIX_FMT_YUYV
,
260 .types
= VPE_FMT_TYPE_CAPTURE
| VPE_FMT_TYPE_OUTPUT
,
262 .vpdma_fmt
= { &vpdma_yuv_fmts
[VPDMA_DATA_FMT_YCB422
],
266 .name
= "UYVY 422 packed",
267 .fourcc
= V4L2_PIX_FMT_UYVY
,
268 .types
= VPE_FMT_TYPE_CAPTURE
| VPE_FMT_TYPE_OUTPUT
,
270 .vpdma_fmt
= { &vpdma_yuv_fmts
[VPDMA_DATA_FMT_CBY422
],
274 .name
= "RGB888 packed",
275 .fourcc
= V4L2_PIX_FMT_RGB24
,
276 .types
= VPE_FMT_TYPE_CAPTURE
,
278 .vpdma_fmt
= { &vpdma_rgb_fmts
[VPDMA_DATA_FMT_RGB24
],
283 .fourcc
= V4L2_PIX_FMT_RGB32
,
284 .types
= VPE_FMT_TYPE_CAPTURE
,
286 .vpdma_fmt
= { &vpdma_rgb_fmts
[VPDMA_DATA_FMT_ARGB32
],
290 .name
= "BGR888 packed",
291 .fourcc
= V4L2_PIX_FMT_BGR24
,
292 .types
= VPE_FMT_TYPE_CAPTURE
,
294 .vpdma_fmt
= { &vpdma_rgb_fmts
[VPDMA_DATA_FMT_BGR24
],
299 .fourcc
= V4L2_PIX_FMT_BGR32
,
300 .types
= VPE_FMT_TYPE_CAPTURE
,
302 .vpdma_fmt
= { &vpdma_rgb_fmts
[VPDMA_DATA_FMT_ABGR32
],
307 .fourcc
= V4L2_PIX_FMT_RGB565
,
308 .types
= VPE_FMT_TYPE_CAPTURE
,
310 .vpdma_fmt
= { &vpdma_rgb_fmts
[VPDMA_DATA_FMT_RGB565
],
315 .fourcc
= V4L2_PIX_FMT_RGB555
,
316 .types
= VPE_FMT_TYPE_CAPTURE
,
318 .vpdma_fmt
= { &vpdma_rgb_fmts
[VPDMA_DATA_FMT_RGBA16_5551
],
324 * per-queue, driver-specific private data.
325 * there is one source queue and one destination queue for each m2m context.
328 unsigned int width
; /* frame width */
329 unsigned int height
; /* frame height */
330 unsigned int nplanes
; /* Current number of planes */
331 unsigned int bytesperline
[VPE_MAX_PLANES
]; /* bytes per line in memory */
332 enum v4l2_colorspace colorspace
;
333 enum v4l2_field field
; /* supported field value */
335 unsigned int sizeimage
[VPE_MAX_PLANES
]; /* image size in memory */
336 struct v4l2_rect c_rect
; /* crop/compose rectangle */
337 struct vpe_fmt
*fmt
; /* format info */
340 /* vpe_q_data flag bits */
341 #define Q_DATA_FRAME_1D BIT(0)
342 #define Q_DATA_MODE_TILED BIT(1)
343 #define Q_DATA_INTERLACED_ALTERNATE BIT(2)
344 #define Q_DATA_INTERLACED_SEQ_TB BIT(3)
346 #define Q_IS_INTERLACED (Q_DATA_INTERLACED_ALTERNATE | \
347 Q_DATA_INTERLACED_SEQ_TB)
354 /* find our format description corresponding to the passed v4l2_format */
355 static struct vpe_fmt
*find_format(struct v4l2_format
*f
)
360 for (k
= 0; k
< ARRAY_SIZE(vpe_formats
); k
++) {
361 fmt
= &vpe_formats
[k
];
362 if (fmt
->fourcc
== f
->fmt
.pix
.pixelformat
)
370 * there is one vpe_dev structure in the driver, it is shared by
374 struct v4l2_device v4l2_dev
;
375 struct video_device vfd
;
376 struct v4l2_m2m_dev
*m2m_dev
;
378 atomic_t num_instances
; /* count of driver instances */
379 dma_addr_t loaded_mmrs
; /* shadow mmrs in device */
380 struct mutex dev_mutex
;
385 struct resource
*res
;
387 struct vpdma_data vpdma_data
;
388 struct vpdma_data
*vpdma
; /* vpdma data handle */
389 struct sc_data
*sc
; /* scaler data handle */
390 struct csc_data
*csc
; /* csc data handle */
394 * There is one vpe_ctx structure for each m2m context.
399 struct v4l2_ctrl_handler hdl
;
401 unsigned int field
; /* current field */
402 unsigned int sequence
; /* current frame/field seq */
403 unsigned int aborting
; /* abort after next irq */
405 unsigned int bufs_per_job
; /* input buffers per batch */
406 unsigned int bufs_completed
; /* bufs done in this batch */
408 struct vpe_q_data q_data
[2]; /* src & dst queue data */
409 struct vb2_v4l2_buffer
*src_vbs
[VPE_MAX_SRC_BUFS
];
410 struct vb2_v4l2_buffer
*dst_vb
;
412 dma_addr_t mv_buf_dma
[2]; /* dma addrs of motion vector in/out bufs */
413 void *mv_buf
[2]; /* virtual addrs of motion vector bufs */
414 size_t mv_buf_size
; /* current motion vector buffer size */
415 struct vpdma_buf mmr_adb
; /* shadow reg addr/data block */
416 struct vpdma_buf sc_coeff_h
; /* h coeff buffer */
417 struct vpdma_buf sc_coeff_v
; /* v coeff buffer */
418 struct vpdma_desc_list desc_list
; /* DMA descriptor list */
420 bool deinterlacing
; /* using de-interlacer */
421 bool load_mmrs
; /* have new shadow reg values */
423 unsigned int src_mv_buf_selector
;
428 * M2M devices get 2 queues.
429 * Return the queue given the type.
431 static struct vpe_q_data
*get_q_data(struct vpe_ctx
*ctx
,
432 enum v4l2_buf_type type
)
435 case V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE
:
436 case V4L2_BUF_TYPE_VIDEO_OUTPUT
:
437 return &ctx
->q_data
[Q_DATA_SRC
];
438 case V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE
:
439 case V4L2_BUF_TYPE_VIDEO_CAPTURE
:
440 return &ctx
->q_data
[Q_DATA_DST
];
447 static u32
read_reg(struct vpe_dev
*dev
, int offset
)
449 return ioread32(dev
->base
+ offset
);
452 static void write_reg(struct vpe_dev
*dev
, int offset
, u32 value
)
454 iowrite32(value
, dev
->base
+ offset
);
457 /* register field read/write helpers */
458 static int get_field(u32 value
, u32 mask
, int shift
)
460 return (value
& (mask
<< shift
)) >> shift
;
463 static int read_field_reg(struct vpe_dev
*dev
, int offset
, u32 mask
, int shift
)
465 return get_field(read_reg(dev
, offset
), mask
, shift
);
468 static void write_field(u32
*valp
, u32 field
, u32 mask
, int shift
)
472 val
&= ~(mask
<< shift
);
473 val
|= (field
& mask
) << shift
;
477 static void write_field_reg(struct vpe_dev
*dev
, int offset
, u32 field
,
480 u32 val
= read_reg(dev
, offset
);
482 write_field(&val
, field
, mask
, shift
);
484 write_reg(dev
, offset
, val
);
488 * DMA address/data block for the shadow registers
491 struct vpdma_adb_hdr out_fmt_hdr
;
494 struct vpdma_adb_hdr us1_hdr
;
496 struct vpdma_adb_hdr us2_hdr
;
498 struct vpdma_adb_hdr us3_hdr
;
500 struct vpdma_adb_hdr dei_hdr
;
502 struct vpdma_adb_hdr sc_hdr0
;
505 struct vpdma_adb_hdr sc_hdr8
;
508 struct vpdma_adb_hdr sc_hdr17
;
511 struct vpdma_adb_hdr csc_hdr
;
516 #define GET_OFFSET_TOP(ctx, obj, reg) \
517 ((obj)->res->start - ctx->dev->res->start + reg)
519 #define VPE_SET_MMR_ADB_HDR(ctx, hdr, regs, offset_a) \
520 VPDMA_SET_MMR_ADB_HDR(ctx->mmr_adb, vpe_mmr_adb, hdr, regs, offset_a)
522 * Set the headers for all of the address/data block structures.
524 static void init_adb_hdrs(struct vpe_ctx
*ctx
)
526 VPE_SET_MMR_ADB_HDR(ctx
, out_fmt_hdr
, out_fmt_reg
, VPE_CLK_FORMAT_SELECT
);
527 VPE_SET_MMR_ADB_HDR(ctx
, us1_hdr
, us1_regs
, VPE_US1_R0
);
528 VPE_SET_MMR_ADB_HDR(ctx
, us2_hdr
, us2_regs
, VPE_US2_R0
);
529 VPE_SET_MMR_ADB_HDR(ctx
, us3_hdr
, us3_regs
, VPE_US3_R0
);
530 VPE_SET_MMR_ADB_HDR(ctx
, dei_hdr
, dei_regs
, VPE_DEI_FRAME_SIZE
);
531 VPE_SET_MMR_ADB_HDR(ctx
, sc_hdr0
, sc_regs0
,
532 GET_OFFSET_TOP(ctx
, ctx
->dev
->sc
, CFG_SC0
));
533 VPE_SET_MMR_ADB_HDR(ctx
, sc_hdr8
, sc_regs8
,
534 GET_OFFSET_TOP(ctx
, ctx
->dev
->sc
, CFG_SC8
));
535 VPE_SET_MMR_ADB_HDR(ctx
, sc_hdr17
, sc_regs17
,
536 GET_OFFSET_TOP(ctx
, ctx
->dev
->sc
, CFG_SC17
));
537 VPE_SET_MMR_ADB_HDR(ctx
, csc_hdr
, csc_regs
,
538 GET_OFFSET_TOP(ctx
, ctx
->dev
->csc
, CSC_CSC00
));
542 * Allocate or re-allocate the motion vector DMA buffers
543 * There are two buffers, one for input and one for output.
544 * However, the roles are reversed after each field is processed.
545 * In other words, after each field is processed, the previous
546 * output (dst) MV buffer becomes the new input (src) MV buffer.
548 static int realloc_mv_buffers(struct vpe_ctx
*ctx
, size_t size
)
550 struct device
*dev
= ctx
->dev
->v4l2_dev
.dev
;
552 if (ctx
->mv_buf_size
== size
)
556 dma_free_coherent(dev
, ctx
->mv_buf_size
, ctx
->mv_buf
[0],
560 dma_free_coherent(dev
, ctx
->mv_buf_size
, ctx
->mv_buf
[1],
566 ctx
->mv_buf
[0] = dma_alloc_coherent(dev
, size
, &ctx
->mv_buf_dma
[0],
568 if (!ctx
->mv_buf
[0]) {
569 vpe_err(ctx
->dev
, "failed to allocate motion vector buffer\n");
573 ctx
->mv_buf
[1] = dma_alloc_coherent(dev
, size
, &ctx
->mv_buf_dma
[1],
575 if (!ctx
->mv_buf
[1]) {
576 vpe_err(ctx
->dev
, "failed to allocate motion vector buffer\n");
577 dma_free_coherent(dev
, size
, ctx
->mv_buf
[0],
583 ctx
->mv_buf_size
= size
;
584 ctx
->src_mv_buf_selector
= 0;
589 static void free_mv_buffers(struct vpe_ctx
*ctx
)
591 realloc_mv_buffers(ctx
, 0);
595 * While de-interlacing, we keep the two most recent input buffers
596 * around. This function frees those two buffers when we have
597 * finished processing the current stream.
599 static void free_vbs(struct vpe_ctx
*ctx
)
601 struct vpe_dev
*dev
= ctx
->dev
;
604 if (ctx
->src_vbs
[2] == NULL
)
607 spin_lock_irqsave(&dev
->lock
, flags
);
608 if (ctx
->src_vbs
[2]) {
609 v4l2_m2m_buf_done(ctx
->src_vbs
[2], VB2_BUF_STATE_DONE
);
610 if (ctx
->src_vbs
[1] && (ctx
->src_vbs
[1] != ctx
->src_vbs
[2]))
611 v4l2_m2m_buf_done(ctx
->src_vbs
[1], VB2_BUF_STATE_DONE
);
612 ctx
->src_vbs
[2] = NULL
;
613 ctx
->src_vbs
[1] = NULL
;
615 spin_unlock_irqrestore(&dev
->lock
, flags
);
619 * Enable or disable the VPE clocks
621 static void vpe_set_clock_enable(struct vpe_dev
*dev
, bool on
)
626 val
= VPE_DATA_PATH_CLK_ENABLE
| VPE_VPEDMA_CLK_ENABLE
;
627 write_reg(dev
, VPE_CLK_ENABLE
, val
);
630 static void vpe_top_reset(struct vpe_dev
*dev
)
633 write_field_reg(dev
, VPE_CLK_RESET
, 1, VPE_DATA_PATH_CLK_RESET_MASK
,
634 VPE_DATA_PATH_CLK_RESET_SHIFT
);
636 usleep_range(100, 150);
638 write_field_reg(dev
, VPE_CLK_RESET
, 0, VPE_DATA_PATH_CLK_RESET_MASK
,
639 VPE_DATA_PATH_CLK_RESET_SHIFT
);
642 static void vpe_top_vpdma_reset(struct vpe_dev
*dev
)
644 write_field_reg(dev
, VPE_CLK_RESET
, 1, VPE_VPDMA_CLK_RESET_MASK
,
645 VPE_VPDMA_CLK_RESET_SHIFT
);
647 usleep_range(100, 150);
649 write_field_reg(dev
, VPE_CLK_RESET
, 0, VPE_VPDMA_CLK_RESET_MASK
,
650 VPE_VPDMA_CLK_RESET_SHIFT
);
654 * Load the correct of upsampler coefficients into the shadow MMRs
656 static void set_us_coefficients(struct vpe_ctx
*ctx
)
658 struct vpe_mmr_adb
*mmr_adb
= ctx
->mmr_adb
.addr
;
659 struct vpe_q_data
*s_q_data
= &ctx
->q_data
[Q_DATA_SRC
];
660 u32
*us1_reg
= &mmr_adb
->us1_regs
[0];
661 u32
*us2_reg
= &mmr_adb
->us2_regs
[0];
662 u32
*us3_reg
= &mmr_adb
->us3_regs
[0];
663 const unsigned short *cp
, *end_cp
;
665 cp
= &us_coeffs
[0].anchor_fid0_c0
;
667 if (s_q_data
->flags
& Q_IS_INTERLACED
) /* interlaced */
668 cp
+= sizeof(us_coeffs
[0]) / sizeof(*cp
);
670 end_cp
= cp
+ sizeof(us_coeffs
[0]) / sizeof(*cp
);
672 while (cp
< end_cp
) {
673 write_field(us1_reg
, *cp
++, VPE_US_C0_MASK
, VPE_US_C0_SHIFT
);
674 write_field(us1_reg
, *cp
++, VPE_US_C1_MASK
, VPE_US_C1_SHIFT
);
675 *us2_reg
++ = *us1_reg
;
676 *us3_reg
++ = *us1_reg
++;
678 ctx
->load_mmrs
= true;
682 * Set the upsampler config mode and the VPDMA line mode in the shadow MMRs.
684 static void set_cfg_modes(struct vpe_ctx
*ctx
)
686 struct vpe_fmt
*fmt
= ctx
->q_data
[Q_DATA_SRC
].fmt
;
687 struct vpe_mmr_adb
*mmr_adb
= ctx
->mmr_adb
.addr
;
688 u32
*us1_reg0
= &mmr_adb
->us1_regs
[0];
689 u32
*us2_reg0
= &mmr_adb
->us2_regs
[0];
690 u32
*us3_reg0
= &mmr_adb
->us3_regs
[0];
694 * Cfg Mode 0: YUV420 source, enable upsampler, DEI is de-interlacing.
695 * Cfg Mode 1: YUV422 source, disable upsampler, DEI is de-interlacing.
698 if (fmt
->fourcc
== V4L2_PIX_FMT_NV12
)
701 write_field(us1_reg0
, cfg_mode
, VPE_US_MODE_MASK
, VPE_US_MODE_SHIFT
);
702 write_field(us2_reg0
, cfg_mode
, VPE_US_MODE_MASK
, VPE_US_MODE_SHIFT
);
703 write_field(us3_reg0
, cfg_mode
, VPE_US_MODE_MASK
, VPE_US_MODE_SHIFT
);
705 ctx
->load_mmrs
= true;
708 static void set_line_modes(struct vpe_ctx
*ctx
)
710 struct vpe_fmt
*fmt
= ctx
->q_data
[Q_DATA_SRC
].fmt
;
713 if (fmt
->fourcc
== V4L2_PIX_FMT_NV12
)
714 line_mode
= 0; /* double lines to line buffer */
717 vpdma_set_line_mode(ctx
->dev
->vpdma
, line_mode
, VPE_CHAN_CHROMA1_IN
);
718 vpdma_set_line_mode(ctx
->dev
->vpdma
, line_mode
, VPE_CHAN_CHROMA2_IN
);
719 vpdma_set_line_mode(ctx
->dev
->vpdma
, line_mode
, VPE_CHAN_CHROMA3_IN
);
721 /* frame start for input luma */
722 vpdma_set_frame_start_event(ctx
->dev
->vpdma
, VPDMA_FSEVENT_CHANNEL_ACTIVE
,
724 vpdma_set_frame_start_event(ctx
->dev
->vpdma
, VPDMA_FSEVENT_CHANNEL_ACTIVE
,
726 vpdma_set_frame_start_event(ctx
->dev
->vpdma
, VPDMA_FSEVENT_CHANNEL_ACTIVE
,
729 /* frame start for input chroma */
730 vpdma_set_frame_start_event(ctx
->dev
->vpdma
, VPDMA_FSEVENT_CHANNEL_ACTIVE
,
731 VPE_CHAN_CHROMA1_IN
);
732 vpdma_set_frame_start_event(ctx
->dev
->vpdma
, VPDMA_FSEVENT_CHANNEL_ACTIVE
,
733 VPE_CHAN_CHROMA2_IN
);
734 vpdma_set_frame_start_event(ctx
->dev
->vpdma
, VPDMA_FSEVENT_CHANNEL_ACTIVE
,
735 VPE_CHAN_CHROMA3_IN
);
737 /* frame start for MV in client */
738 vpdma_set_frame_start_event(ctx
->dev
->vpdma
, VPDMA_FSEVENT_CHANNEL_ACTIVE
,
743 * Set the shadow registers that are modified when the source
746 static void set_src_registers(struct vpe_ctx
*ctx
)
748 set_us_coefficients(ctx
);
752 * Set the shadow registers that are modified when the destination
755 static void set_dst_registers(struct vpe_ctx
*ctx
)
757 struct vpe_mmr_adb
*mmr_adb
= ctx
->mmr_adb
.addr
;
758 enum v4l2_colorspace clrspc
= ctx
->q_data
[Q_DATA_DST
].colorspace
;
759 struct vpe_fmt
*fmt
= ctx
->q_data
[Q_DATA_DST
].fmt
;
762 if (clrspc
== V4L2_COLORSPACE_SRGB
) {
763 val
|= VPE_RGB_OUT_SELECT
;
764 vpdma_set_bg_color(ctx
->dev
->vpdma
,
765 (struct vpdma_data_format
*)fmt
->vpdma_fmt
[0], 0xff);
766 } else if (fmt
->fourcc
== V4L2_PIX_FMT_NV16
)
767 val
|= VPE_COLOR_SEPARATE_422
;
770 * the source of CHR_DS and CSC is always the scaler, irrespective of
771 * whether it's used or not
773 val
|= VPE_DS_SRC_DEI_SCALER
| VPE_CSC_SRC_DEI_SCALER
;
775 if (fmt
->fourcc
!= V4L2_PIX_FMT_NV12
)
776 val
|= VPE_DS_BYPASS
;
778 mmr_adb
->out_fmt_reg
[0] = val
;
780 ctx
->load_mmrs
= true;
784 * Set the de-interlacer shadow register values
786 static void set_dei_regs(struct vpe_ctx
*ctx
)
788 struct vpe_mmr_adb
*mmr_adb
= ctx
->mmr_adb
.addr
;
789 struct vpe_q_data
*s_q_data
= &ctx
->q_data
[Q_DATA_SRC
];
790 unsigned int src_h
= s_q_data
->c_rect
.height
;
791 unsigned int src_w
= s_q_data
->c_rect
.width
;
792 u32
*dei_mmr0
= &mmr_adb
->dei_regs
[0];
793 bool deinterlace
= true;
797 * according to TRM, we should set DEI in progressive bypass mode when
798 * the input content is progressive, however, DEI is bypassed correctly
799 * for both progressive and interlace content in interlace bypass mode.
800 * It has been recommended not to use progressive bypass mode.
802 if (!(s_q_data
->flags
& Q_IS_INTERLACED
) || !ctx
->deinterlacing
) {
804 val
= VPE_DEI_INTERLACE_BYPASS
;
807 src_h
= deinterlace
? src_h
* 2 : src_h
;
809 val
|= (src_h
<< VPE_DEI_HEIGHT_SHIFT
) |
810 (src_w
<< VPE_DEI_WIDTH_SHIFT
) |
815 ctx
->load_mmrs
= true;
818 static void set_dei_shadow_registers(struct vpe_ctx
*ctx
)
820 struct vpe_mmr_adb
*mmr_adb
= ctx
->mmr_adb
.addr
;
821 u32
*dei_mmr
= &mmr_adb
->dei_regs
[0];
822 const struct vpe_dei_regs
*cur
= &dei_regs
;
824 dei_mmr
[2] = cur
->mdt_spacial_freq_thr_reg
;
825 dei_mmr
[3] = cur
->edi_config_reg
;
826 dei_mmr
[4] = cur
->edi_lut_reg0
;
827 dei_mmr
[5] = cur
->edi_lut_reg1
;
828 dei_mmr
[6] = cur
->edi_lut_reg2
;
829 dei_mmr
[7] = cur
->edi_lut_reg3
;
831 ctx
->load_mmrs
= true;
834 static void config_edi_input_mode(struct vpe_ctx
*ctx
, int mode
)
836 struct vpe_mmr_adb
*mmr_adb
= ctx
->mmr_adb
.addr
;
837 u32
*edi_config_reg
= &mmr_adb
->dei_regs
[3];
840 write_field(edi_config_reg
, 1, 1, 2); /* EDI_ENABLE_3D */
843 write_field(edi_config_reg
, 1, 1, 3); /* EDI_CHROMA_3D */
845 write_field(edi_config_reg
, mode
, VPE_EDI_INP_MODE_MASK
,
846 VPE_EDI_INP_MODE_SHIFT
);
848 ctx
->load_mmrs
= true;
852 * Set the shadow registers whose values are modified when either the
853 * source or destination format is changed.
855 static int set_srcdst_params(struct vpe_ctx
*ctx
)
857 struct vpe_q_data
*s_q_data
= &ctx
->q_data
[Q_DATA_SRC
];
858 struct vpe_q_data
*d_q_data
= &ctx
->q_data
[Q_DATA_DST
];
859 struct vpe_mmr_adb
*mmr_adb
= ctx
->mmr_adb
.addr
;
860 unsigned int src_w
= s_q_data
->c_rect
.width
;
861 unsigned int src_h
= s_q_data
->c_rect
.height
;
862 unsigned int dst_w
= d_q_data
->c_rect
.width
;
863 unsigned int dst_h
= d_q_data
->c_rect
.height
;
868 ctx
->field
= V4L2_FIELD_TOP
;
870 if ((s_q_data
->flags
& Q_IS_INTERLACED
) &&
871 !(d_q_data
->flags
& Q_IS_INTERLACED
)) {
873 const struct vpdma_data_format
*mv
=
874 &vpdma_misc_fmts
[VPDMA_DATA_FMT_MV
];
877 * we make sure that the source image has a 16 byte aligned
878 * stride, we need to do the same for the motion vector buffer
879 * by aligning it's stride to the next 16 byte boundry. this
880 * extra space will not be used by the de-interlacer, but will
881 * ensure that vpdma operates correctly
883 bytes_per_line
= ALIGN((s_q_data
->width
* mv
->depth
) >> 3,
885 mv_buf_size
= bytes_per_line
* s_q_data
->height
;
887 ctx
->deinterlacing
= true;
890 ctx
->deinterlacing
= false;
895 ctx
->src_vbs
[2] = ctx
->src_vbs
[1] = ctx
->src_vbs
[0] = NULL
;
897 ret
= realloc_mv_buffers(ctx
, mv_buf_size
);
904 csc_set_coeff(ctx
->dev
->csc
, &mmr_adb
->csc_regs
[0],
905 s_q_data
->colorspace
, d_q_data
->colorspace
);
907 sc_set_hs_coeffs(ctx
->dev
->sc
, ctx
->sc_coeff_h
.addr
, src_w
, dst_w
);
908 sc_set_vs_coeffs(ctx
->dev
->sc
, ctx
->sc_coeff_v
.addr
, src_h
, dst_h
);
910 sc_config_scaler(ctx
->dev
->sc
, &mmr_adb
->sc_regs0
[0],
911 &mmr_adb
->sc_regs8
[0], &mmr_adb
->sc_regs17
[0],
912 src_w
, src_h
, dst_w
, dst_h
);
918 * Return the vpe_ctx structure for a given struct file
920 static struct vpe_ctx
*file2ctx(struct file
*file
)
922 return container_of(file
->private_data
, struct vpe_ctx
, fh
);
930 * job_ready() - check whether an instance is ready to be scheduled to run
932 static int job_ready(void *priv
)
934 struct vpe_ctx
*ctx
= priv
;
937 * This check is needed as this might be called directly from driver
938 * When called by m2m framework, this will always satisfy, but when
939 * called from vpe_irq, this might fail. (src stream with zero buffers)
941 if (v4l2_m2m_num_src_bufs_ready(ctx
->fh
.m2m_ctx
) <= 0 ||
942 v4l2_m2m_num_dst_bufs_ready(ctx
->fh
.m2m_ctx
) <= 0)
948 static void job_abort(void *priv
)
950 struct vpe_ctx
*ctx
= priv
;
952 /* Will cancel the transaction in the next interrupt handler */
957 * Lock access to the device
959 static void vpe_lock(void *priv
)
961 struct vpe_ctx
*ctx
= priv
;
962 struct vpe_dev
*dev
= ctx
->dev
;
963 mutex_lock(&dev
->dev_mutex
);
966 static void vpe_unlock(void *priv
)
968 struct vpe_ctx
*ctx
= priv
;
969 struct vpe_dev
*dev
= ctx
->dev
;
970 mutex_unlock(&dev
->dev_mutex
);
973 static void vpe_dump_regs(struct vpe_dev
*dev
)
975 #define DUMPREG(r) vpe_dbg(dev, "%-35s %08x\n", #r, read_reg(dev, VPE_##r))
977 vpe_dbg(dev
, "VPE Registers:\n");
981 DUMPREG(INT0_STATUS0_RAW
);
982 DUMPREG(INT0_STATUS0
);
983 DUMPREG(INT0_ENABLE0
);
984 DUMPREG(INT0_STATUS1_RAW
);
985 DUMPREG(INT0_STATUS1
);
986 DUMPREG(INT0_ENABLE1
);
989 DUMPREG(CLK_FORMAT_SELECT
);
990 DUMPREG(CLK_RANGE_MAP
);
1015 DUMPREG(DEI_FRAME_SIZE
);
1016 DUMPREG(MDT_BYPASS
);
1017 DUMPREG(MDT_SF_THRESHOLD
);
1018 DUMPREG(EDI_CONFIG
);
1019 DUMPREG(DEI_EDI_LUT_R0
);
1020 DUMPREG(DEI_EDI_LUT_R1
);
1021 DUMPREG(DEI_EDI_LUT_R2
);
1022 DUMPREG(DEI_EDI_LUT_R3
);
1023 DUMPREG(DEI_FMD_WINDOW_R0
);
1024 DUMPREG(DEI_FMD_WINDOW_R1
);
1025 DUMPREG(DEI_FMD_CONTROL_R0
);
1026 DUMPREG(DEI_FMD_CONTROL_R1
);
1027 DUMPREG(DEI_FMD_STATUS_R0
);
1028 DUMPREG(DEI_FMD_STATUS_R1
);
1029 DUMPREG(DEI_FMD_STATUS_R2
);
1032 sc_dump_regs(dev
->sc
);
1033 csc_dump_regs(dev
->csc
);
1036 static void add_out_dtd(struct vpe_ctx
*ctx
, int port
)
1038 struct vpe_q_data
*q_data
= &ctx
->q_data
[Q_DATA_DST
];
1039 const struct vpe_port_data
*p_data
= &port_data
[port
];
1040 struct vb2_buffer
*vb
= &ctx
->dst_vb
->vb2_buf
;
1041 struct vpe_fmt
*fmt
= q_data
->fmt
;
1042 const struct vpdma_data_format
*vpdma_fmt
;
1043 int mv_buf_selector
= !ctx
->src_mv_buf_selector
;
1044 dma_addr_t dma_addr
;
1048 if (port
== VPE_PORT_MV_OUT
) {
1049 vpdma_fmt
= &vpdma_misc_fmts
[VPDMA_DATA_FMT_MV
];
1050 dma_addr
= ctx
->mv_buf_dma
[mv_buf_selector
];
1051 q_data
= &ctx
->q_data
[Q_DATA_SRC
];
1053 /* to incorporate interleaved formats */
1054 int plane
= fmt
->coplanar
? p_data
->vb_part
: 0;
1056 vpdma_fmt
= fmt
->vpdma_fmt
[plane
];
1058 * If we are using a single plane buffer and
1059 * we need to set a separate vpdma chroma channel.
1061 if (q_data
->nplanes
== 1 && plane
) {
1062 dma_addr
= vb2_dma_contig_plane_dma_addr(vb
, 0);
1063 /* Compute required offset */
1064 offset
= q_data
->bytesperline
[0] * q_data
->height
;
1066 dma_addr
= vb2_dma_contig_plane_dma_addr(vb
, plane
);
1067 /* Use address as is, no offset */
1072 "acquiring output buffer(%d) dma_addr failed\n",
1076 /* Apply the offset */
1080 if (q_data
->flags
& Q_DATA_FRAME_1D
)
1081 flags
|= VPDMA_DATA_FRAME_1D
;
1082 if (q_data
->flags
& Q_DATA_MODE_TILED
)
1083 flags
|= VPDMA_DATA_MODE_TILED
;
1085 vpdma_set_max_size(ctx
->dev
->vpdma
, VPDMA_MAX_SIZE1
,
1088 vpdma_add_out_dtd(&ctx
->desc_list
, q_data
->width
,
1089 q_data
->bytesperline
[VPE_LUMA
], &q_data
->c_rect
,
1090 vpdma_fmt
, dma_addr
, MAX_OUT_WIDTH_REG1
,
1091 MAX_OUT_HEIGHT_REG1
, p_data
->channel
, flags
);
1094 static void add_in_dtd(struct vpe_ctx
*ctx
, int port
)
1096 struct vpe_q_data
*q_data
= &ctx
->q_data
[Q_DATA_SRC
];
1097 const struct vpe_port_data
*p_data
= &port_data
[port
];
1098 struct vb2_buffer
*vb
= &ctx
->src_vbs
[p_data
->vb_index
]->vb2_buf
;
1099 struct vb2_v4l2_buffer
*vbuf
= to_vb2_v4l2_buffer(vb
);
1100 struct vpe_fmt
*fmt
= q_data
->fmt
;
1101 const struct vpdma_data_format
*vpdma_fmt
;
1102 int mv_buf_selector
= ctx
->src_mv_buf_selector
;
1103 int field
= vbuf
->field
== V4L2_FIELD_BOTTOM
;
1104 int frame_width
, frame_height
;
1105 dma_addr_t dma_addr
;
1109 if (port
== VPE_PORT_MV_IN
) {
1110 vpdma_fmt
= &vpdma_misc_fmts
[VPDMA_DATA_FMT_MV
];
1111 dma_addr
= ctx
->mv_buf_dma
[mv_buf_selector
];
1113 /* to incorporate interleaved formats */
1114 int plane
= fmt
->coplanar
? p_data
->vb_part
: 0;
1116 vpdma_fmt
= fmt
->vpdma_fmt
[plane
];
1118 * If we are using a single plane buffer and
1119 * we need to set a separate vpdma chroma channel.
1121 if (q_data
->nplanes
== 1 && plane
) {
1122 dma_addr
= vb2_dma_contig_plane_dma_addr(vb
, 0);
1123 /* Compute required offset */
1124 offset
= q_data
->bytesperline
[0] * q_data
->height
;
1126 dma_addr
= vb2_dma_contig_plane_dma_addr(vb
, plane
);
1127 /* Use address as is, no offset */
1132 "acquiring output buffer(%d) dma_addr failed\n",
1136 /* Apply the offset */
1139 if (q_data
->flags
& Q_DATA_INTERLACED_SEQ_TB
) {
1141 * Use top or bottom field from same vb alternately
1142 * f,f-1,f-2 = TBT when seq is even
1143 * f,f-1,f-2 = BTB when seq is odd
1145 field
= (p_data
->vb_index
+ (ctx
->sequence
% 2)) % 2;
1149 * bottom field of a SEQ_TB buffer
1150 * Skip the top field data by
1152 int height
= q_data
->height
/ 2;
1153 int bpp
= fmt
->fourcc
== V4L2_PIX_FMT_NV12
?
1154 1 : (vpdma_fmt
->depth
>> 3);
1157 dma_addr
+= q_data
->width
* height
* bpp
;
1162 if (q_data
->flags
& Q_DATA_FRAME_1D
)
1163 flags
|= VPDMA_DATA_FRAME_1D
;
1164 if (q_data
->flags
& Q_DATA_MODE_TILED
)
1165 flags
|= VPDMA_DATA_MODE_TILED
;
1167 frame_width
= q_data
->c_rect
.width
;
1168 frame_height
= q_data
->c_rect
.height
;
1170 if (p_data
->vb_part
&& fmt
->fourcc
== V4L2_PIX_FMT_NV12
)
1173 vpdma_add_in_dtd(&ctx
->desc_list
, q_data
->width
,
1174 q_data
->bytesperline
[VPE_LUMA
], &q_data
->c_rect
,
1175 vpdma_fmt
, dma_addr
, p_data
->channel
, field
, flags
, frame_width
,
1176 frame_height
, 0, 0);
1180 * Enable the expected IRQ sources
1182 static void enable_irqs(struct vpe_ctx
*ctx
)
1184 write_reg(ctx
->dev
, VPE_INT0_ENABLE0_SET
, VPE_INT0_LIST0_COMPLETE
);
1185 write_reg(ctx
->dev
, VPE_INT0_ENABLE1_SET
, VPE_DEI_ERROR_INT
|
1186 VPE_DS1_UV_ERROR_INT
);
1188 vpdma_enable_list_complete_irq(ctx
->dev
->vpdma
, 0, 0, true);
1191 static void disable_irqs(struct vpe_ctx
*ctx
)
1193 write_reg(ctx
->dev
, VPE_INT0_ENABLE0_CLR
, 0xffffffff);
1194 write_reg(ctx
->dev
, VPE_INT0_ENABLE1_CLR
, 0xffffffff);
1196 vpdma_enable_list_complete_irq(ctx
->dev
->vpdma
, 0, 0, false);
1199 /* device_run() - prepares and starts the device
1201 * This function is only called when both the source and destination
1202 * buffers are in place.
1204 static void device_run(void *priv
)
1206 struct vpe_ctx
*ctx
= priv
;
1207 struct sc_data
*sc
= ctx
->dev
->sc
;
1208 struct vpe_q_data
*d_q_data
= &ctx
->q_data
[Q_DATA_DST
];
1209 struct vpe_q_data
*s_q_data
= &ctx
->q_data
[Q_DATA_SRC
];
1211 if (ctx
->deinterlacing
&& s_q_data
->flags
& Q_DATA_INTERLACED_SEQ_TB
&&
1212 ctx
->sequence
% 2 == 0) {
1213 /* When using SEQ_TB buffers, When using it first time,
1214 * No need to remove the buffer as the next field is present
1215 * in the same buffer. (so that job_ready won't fail)
1216 * It will be removed when using bottom field
1218 ctx
->src_vbs
[0] = v4l2_m2m_next_src_buf(ctx
->fh
.m2m_ctx
);
1219 WARN_ON(ctx
->src_vbs
[0] == NULL
);
1221 ctx
->src_vbs
[0] = v4l2_m2m_src_buf_remove(ctx
->fh
.m2m_ctx
);
1222 WARN_ON(ctx
->src_vbs
[0] == NULL
);
1225 ctx
->dst_vb
= v4l2_m2m_dst_buf_remove(ctx
->fh
.m2m_ctx
);
1226 WARN_ON(ctx
->dst_vb
== NULL
);
1228 if (ctx
->deinterlacing
) {
1230 if (ctx
->src_vbs
[2] == NULL
) {
1231 ctx
->src_vbs
[2] = ctx
->src_vbs
[0];
1232 WARN_ON(ctx
->src_vbs
[2] == NULL
);
1233 ctx
->src_vbs
[1] = ctx
->src_vbs
[0];
1234 WARN_ON(ctx
->src_vbs
[1] == NULL
);
1238 * we have output the first 2 frames through line average, we
1239 * now switch to EDI de-interlacer
1241 if (ctx
->sequence
== 2)
1242 config_edi_input_mode(ctx
, 0x3); /* EDI (Y + UV) */
1245 /* config descriptors */
1246 if (ctx
->dev
->loaded_mmrs
!= ctx
->mmr_adb
.dma_addr
|| ctx
->load_mmrs
) {
1247 vpdma_map_desc_buf(ctx
->dev
->vpdma
, &ctx
->mmr_adb
);
1248 vpdma_add_cfd_adb(&ctx
->desc_list
, CFD_MMR_CLIENT
, &ctx
->mmr_adb
);
1250 set_line_modes(ctx
);
1252 ctx
->dev
->loaded_mmrs
= ctx
->mmr_adb
.dma_addr
;
1253 ctx
->load_mmrs
= false;
1256 if (sc
->loaded_coeff_h
!= ctx
->sc_coeff_h
.dma_addr
||
1258 vpdma_map_desc_buf(ctx
->dev
->vpdma
, &ctx
->sc_coeff_h
);
1259 vpdma_add_cfd_block(&ctx
->desc_list
, CFD_SC_CLIENT
,
1260 &ctx
->sc_coeff_h
, 0);
1262 sc
->loaded_coeff_h
= ctx
->sc_coeff_h
.dma_addr
;
1263 sc
->load_coeff_h
= false;
1266 if (sc
->loaded_coeff_v
!= ctx
->sc_coeff_v
.dma_addr
||
1268 vpdma_map_desc_buf(ctx
->dev
->vpdma
, &ctx
->sc_coeff_v
);
1269 vpdma_add_cfd_block(&ctx
->desc_list
, CFD_SC_CLIENT
,
1270 &ctx
->sc_coeff_v
, SC_COEF_SRAM_SIZE
>> 4);
1272 sc
->loaded_coeff_v
= ctx
->sc_coeff_v
.dma_addr
;
1273 sc
->load_coeff_v
= false;
1276 /* output data descriptors */
1277 if (ctx
->deinterlacing
)
1278 add_out_dtd(ctx
, VPE_PORT_MV_OUT
);
1280 if (d_q_data
->colorspace
== V4L2_COLORSPACE_SRGB
) {
1281 add_out_dtd(ctx
, VPE_PORT_RGB_OUT
);
1283 add_out_dtd(ctx
, VPE_PORT_LUMA_OUT
);
1284 if (d_q_data
->fmt
->coplanar
)
1285 add_out_dtd(ctx
, VPE_PORT_CHROMA_OUT
);
1288 /* input data descriptors */
1289 if (ctx
->deinterlacing
) {
1290 add_in_dtd(ctx
, VPE_PORT_LUMA3_IN
);
1291 add_in_dtd(ctx
, VPE_PORT_CHROMA3_IN
);
1293 add_in_dtd(ctx
, VPE_PORT_LUMA2_IN
);
1294 add_in_dtd(ctx
, VPE_PORT_CHROMA2_IN
);
1297 add_in_dtd(ctx
, VPE_PORT_LUMA1_IN
);
1298 add_in_dtd(ctx
, VPE_PORT_CHROMA1_IN
);
1300 if (ctx
->deinterlacing
)
1301 add_in_dtd(ctx
, VPE_PORT_MV_IN
);
1303 /* sync on channel control descriptors for input ports */
1304 vpdma_add_sync_on_channel_ctd(&ctx
->desc_list
, VPE_CHAN_LUMA1_IN
);
1305 vpdma_add_sync_on_channel_ctd(&ctx
->desc_list
, VPE_CHAN_CHROMA1_IN
);
1307 if (ctx
->deinterlacing
) {
1308 vpdma_add_sync_on_channel_ctd(&ctx
->desc_list
,
1310 vpdma_add_sync_on_channel_ctd(&ctx
->desc_list
,
1311 VPE_CHAN_CHROMA2_IN
);
1313 vpdma_add_sync_on_channel_ctd(&ctx
->desc_list
,
1315 vpdma_add_sync_on_channel_ctd(&ctx
->desc_list
,
1316 VPE_CHAN_CHROMA3_IN
);
1318 vpdma_add_sync_on_channel_ctd(&ctx
->desc_list
, VPE_CHAN_MV_IN
);
1321 /* sync on channel control descriptors for output ports */
1322 if (d_q_data
->colorspace
== V4L2_COLORSPACE_SRGB
) {
1323 vpdma_add_sync_on_channel_ctd(&ctx
->desc_list
,
1326 vpdma_add_sync_on_channel_ctd(&ctx
->desc_list
,
1328 if (d_q_data
->fmt
->coplanar
)
1329 vpdma_add_sync_on_channel_ctd(&ctx
->desc_list
,
1330 VPE_CHAN_CHROMA_OUT
);
1333 if (ctx
->deinterlacing
)
1334 vpdma_add_sync_on_channel_ctd(&ctx
->desc_list
, VPE_CHAN_MV_OUT
);
1338 vpdma_map_desc_buf(ctx
->dev
->vpdma
, &ctx
->desc_list
.buf
);
1339 vpdma_submit_descs(ctx
->dev
->vpdma
, &ctx
->desc_list
, 0);
1342 static void dei_error(struct vpe_ctx
*ctx
)
1344 dev_warn(ctx
->dev
->v4l2_dev
.dev
,
1345 "received DEI error interrupt\n");
1348 static void ds1_uv_error(struct vpe_ctx
*ctx
)
1350 dev_warn(ctx
->dev
->v4l2_dev
.dev
,
1351 "received downsampler error interrupt\n");
1354 static irqreturn_t
vpe_irq(int irq_vpe
, void *data
)
1356 struct vpe_dev
*dev
= (struct vpe_dev
*)data
;
1357 struct vpe_ctx
*ctx
;
1358 struct vpe_q_data
*d_q_data
;
1359 struct vb2_v4l2_buffer
*s_vb
, *d_vb
;
1360 unsigned long flags
;
1362 bool list_complete
= false;
1364 irqst0
= read_reg(dev
, VPE_INT0_STATUS0
);
1366 write_reg(dev
, VPE_INT0_STATUS0_CLR
, irqst0
);
1367 vpe_dbg(dev
, "INT0_STATUS0 = 0x%08x\n", irqst0
);
1370 irqst1
= read_reg(dev
, VPE_INT0_STATUS1
);
1372 write_reg(dev
, VPE_INT0_STATUS1_CLR
, irqst1
);
1373 vpe_dbg(dev
, "INT0_STATUS1 = 0x%08x\n", irqst1
);
1376 ctx
= v4l2_m2m_get_curr_priv(dev
->m2m_dev
);
1378 vpe_err(dev
, "instance released before end of transaction\n");
1383 if (irqst1
& VPE_DEI_ERROR_INT
) {
1384 irqst1
&= ~VPE_DEI_ERROR_INT
;
1387 if (irqst1
& VPE_DS1_UV_ERROR_INT
) {
1388 irqst1
&= ~VPE_DS1_UV_ERROR_INT
;
1394 if (irqst0
& VPE_INT0_LIST0_COMPLETE
)
1395 vpdma_clear_list_stat(ctx
->dev
->vpdma
, 0, 0);
1397 irqst0
&= ~(VPE_INT0_LIST0_COMPLETE
);
1398 list_complete
= true;
1401 if (irqst0
| irqst1
) {
1402 dev_warn(dev
->v4l2_dev
.dev
, "Unexpected interrupt: INT0_STATUS0 = 0x%08x, INT0_STATUS1 = 0x%08x\n",
1407 * Setup next operation only when list complete IRQ occurs
1408 * otherwise, skip the following code
1415 vpdma_unmap_desc_buf(dev
->vpdma
, &ctx
->desc_list
.buf
);
1416 vpdma_unmap_desc_buf(dev
->vpdma
, &ctx
->mmr_adb
);
1417 vpdma_unmap_desc_buf(dev
->vpdma
, &ctx
->sc_coeff_h
);
1418 vpdma_unmap_desc_buf(dev
->vpdma
, &ctx
->sc_coeff_v
);
1420 vpdma_reset_desc_list(&ctx
->desc_list
);
1422 /* the previous dst mv buffer becomes the next src mv buffer */
1423 ctx
->src_mv_buf_selector
= !ctx
->src_mv_buf_selector
;
1428 s_vb
= ctx
->src_vbs
[0];
1431 d_vb
->flags
= s_vb
->flags
;
1432 d_vb
->vb2_buf
.timestamp
= s_vb
->vb2_buf
.timestamp
;
1434 if (s_vb
->flags
& V4L2_BUF_FLAG_TIMECODE
)
1435 d_vb
->timecode
= s_vb
->timecode
;
1437 d_vb
->sequence
= ctx
->sequence
;
1439 d_q_data
= &ctx
->q_data
[Q_DATA_DST
];
1440 if (d_q_data
->flags
& Q_IS_INTERLACED
) {
1441 d_vb
->field
= ctx
->field
;
1442 if (ctx
->field
== V4L2_FIELD_BOTTOM
) {
1444 ctx
->field
= V4L2_FIELD_TOP
;
1446 WARN_ON(ctx
->field
!= V4L2_FIELD_TOP
);
1447 ctx
->field
= V4L2_FIELD_BOTTOM
;
1450 d_vb
->field
= V4L2_FIELD_NONE
;
1454 if (ctx
->deinterlacing
) {
1456 * Allow source buffer to be dequeued only if it won't be used
1457 * in the next iteration. All vbs are initialized to first
1458 * buffer and we are shifting buffers every iteration, for the
1459 * first two iterations, no buffer will be dequeued.
1460 * This ensures that driver will keep (n-2)th (n-1)th and (n)th
1461 * field when deinterlacing is enabled
1463 if (ctx
->src_vbs
[2] != ctx
->src_vbs
[1])
1464 s_vb
= ctx
->src_vbs
[2];
1469 spin_lock_irqsave(&dev
->lock
, flags
);
1472 v4l2_m2m_buf_done(s_vb
, VB2_BUF_STATE_DONE
);
1474 v4l2_m2m_buf_done(d_vb
, VB2_BUF_STATE_DONE
);
1476 spin_unlock_irqrestore(&dev
->lock
, flags
);
1478 if (ctx
->deinterlacing
) {
1479 ctx
->src_vbs
[2] = ctx
->src_vbs
[1];
1480 ctx
->src_vbs
[1] = ctx
->src_vbs
[0];
1484 * Since the vb2_buf_done has already been called fir therse
1485 * buffer we can now NULL them out so that we won't try
1486 * to clean out stray pointer later on.
1488 ctx
->src_vbs
[0] = NULL
;
1491 ctx
->bufs_completed
++;
1492 if (ctx
->bufs_completed
< ctx
->bufs_per_job
&& job_ready(ctx
)) {
1498 vpe_dbg(ctx
->dev
, "finishing transaction\n");
1499 ctx
->bufs_completed
= 0;
1500 v4l2_m2m_job_finish(dev
->m2m_dev
, ctx
->fh
.m2m_ctx
);
1508 static int vpe_querycap(struct file
*file
, void *priv
,
1509 struct v4l2_capability
*cap
)
1511 strncpy(cap
->driver
, VPE_MODULE_NAME
, sizeof(cap
->driver
) - 1);
1512 strncpy(cap
->card
, VPE_MODULE_NAME
, sizeof(cap
->card
) - 1);
1513 snprintf(cap
->bus_info
, sizeof(cap
->bus_info
), "platform:%s",
1515 cap
->device_caps
= V4L2_CAP_VIDEO_M2M_MPLANE
| V4L2_CAP_STREAMING
;
1516 cap
->capabilities
= cap
->device_caps
| V4L2_CAP_DEVICE_CAPS
;
1520 static int __enum_fmt(struct v4l2_fmtdesc
*f
, u32 type
)
1523 struct vpe_fmt
*fmt
= NULL
;
1526 for (i
= 0; i
< ARRAY_SIZE(vpe_formats
); ++i
) {
1527 if (vpe_formats
[i
].types
& type
) {
1528 if (index
== f
->index
) {
1529 fmt
= &vpe_formats
[i
];
1539 strncpy(f
->description
, fmt
->name
, sizeof(f
->description
) - 1);
1540 f
->pixelformat
= fmt
->fourcc
;
1544 static int vpe_enum_fmt(struct file
*file
, void *priv
,
1545 struct v4l2_fmtdesc
*f
)
1547 if (V4L2_TYPE_IS_OUTPUT(f
->type
))
1548 return __enum_fmt(f
, VPE_FMT_TYPE_OUTPUT
);
1550 return __enum_fmt(f
, VPE_FMT_TYPE_CAPTURE
);
1553 static int vpe_g_fmt(struct file
*file
, void *priv
, struct v4l2_format
*f
)
1555 struct v4l2_pix_format_mplane
*pix
= &f
->fmt
.pix_mp
;
1556 struct vpe_ctx
*ctx
= file2ctx(file
);
1557 struct vb2_queue
*vq
;
1558 struct vpe_q_data
*q_data
;
1561 vq
= v4l2_m2m_get_vq(ctx
->fh
.m2m_ctx
, f
->type
);
1565 q_data
= get_q_data(ctx
, f
->type
);
1567 pix
->width
= q_data
->width
;
1568 pix
->height
= q_data
->height
;
1569 pix
->pixelformat
= q_data
->fmt
->fourcc
;
1570 pix
->field
= q_data
->field
;
1572 if (V4L2_TYPE_IS_OUTPUT(f
->type
)) {
1573 pix
->colorspace
= q_data
->colorspace
;
1575 struct vpe_q_data
*s_q_data
;
1577 /* get colorspace from the source queue */
1578 s_q_data
= get_q_data(ctx
, V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE
);
1580 pix
->colorspace
= s_q_data
->colorspace
;
1583 pix
->num_planes
= q_data
->nplanes
;
1585 for (i
= 0; i
< pix
->num_planes
; i
++) {
1586 pix
->plane_fmt
[i
].bytesperline
= q_data
->bytesperline
[i
];
1587 pix
->plane_fmt
[i
].sizeimage
= q_data
->sizeimage
[i
];
1593 static int __vpe_try_fmt(struct vpe_ctx
*ctx
, struct v4l2_format
*f
,
1594 struct vpe_fmt
*fmt
, int type
)
1596 struct v4l2_pix_format_mplane
*pix
= &f
->fmt
.pix_mp
;
1597 struct v4l2_plane_pix_format
*plane_fmt
;
1598 unsigned int w_align
;
1599 int i
, depth
, depth_bytes
, height
;
1600 unsigned int stride
= 0;
1602 if (!fmt
|| !(fmt
->types
& type
)) {
1603 vpe_err(ctx
->dev
, "Fourcc format (0x%08x) invalid.\n",
1608 if (pix
->field
!= V4L2_FIELD_NONE
&& pix
->field
!= V4L2_FIELD_ALTERNATE
1609 && pix
->field
!= V4L2_FIELD_SEQ_TB
)
1610 pix
->field
= V4L2_FIELD_NONE
;
1612 depth
= fmt
->vpdma_fmt
[VPE_LUMA
]->depth
;
1615 * the line stride should 16 byte aligned for VPDMA to work, based on
1616 * the bytes per pixel, figure out how much the width should be aligned
1617 * to make sure line stride is 16 byte aligned
1619 depth_bytes
= depth
>> 3;
1621 if (depth_bytes
== 3) {
1623 * if bpp is 3(as in some RGB formats), the pixel width doesn't
1624 * really help in ensuring line stride is 16 byte aligned
1629 * for the remainder bpp(4, 2 and 1), the pixel width alignment
1630 * can ensure a line stride alignment of 16 bytes. For example,
1631 * if bpp is 2, then the line stride can be 16 byte aligned if
1632 * the width is 8 byte aligned
1636 * HACK: using order_base_2() here causes lots of asm output
1637 * errors with smatch, on i386:
1638 * ./arch/x86/include/asm/bitops.h:457:22:
1639 * warning: asm output is not an lvalue
1640 * Perhaps some gcc optimization is doing the wrong thing
1642 * Let's get rid of them by doing the calculus on two steps
1644 w_align
= roundup_pow_of_two(VPDMA_DESC_ALIGN
/ depth_bytes
);
1645 w_align
= ilog2(w_align
);
1648 v4l_bound_align_image(&pix
->width
, MIN_W
, MAX_W
, w_align
,
1649 &pix
->height
, MIN_H
, MAX_H
, H_ALIGN
,
1652 if (!pix
->num_planes
)
1653 pix
->num_planes
= fmt
->coplanar
? 2 : 1;
1654 else if (pix
->num_planes
> 1 && !fmt
->coplanar
)
1655 pix
->num_planes
= 1;
1657 pix
->pixelformat
= fmt
->fourcc
;
1660 * For the actual image parameters, we need to consider the field
1661 * height of the image for SEQ_TB buffers.
1663 if (pix
->field
== V4L2_FIELD_SEQ_TB
)
1664 height
= pix
->height
/ 2;
1666 height
= pix
->height
;
1668 if (!pix
->colorspace
) {
1669 if (fmt
->fourcc
== V4L2_PIX_FMT_RGB24
||
1670 fmt
->fourcc
== V4L2_PIX_FMT_BGR24
||
1671 fmt
->fourcc
== V4L2_PIX_FMT_RGB32
||
1672 fmt
->fourcc
== V4L2_PIX_FMT_BGR32
) {
1673 pix
->colorspace
= V4L2_COLORSPACE_SRGB
;
1675 if (height
> 1280) /* HD */
1676 pix
->colorspace
= V4L2_COLORSPACE_REC709
;
1678 pix
->colorspace
= V4L2_COLORSPACE_SMPTE170M
;
1682 memset(pix
->reserved
, 0, sizeof(pix
->reserved
));
1683 for (i
= 0; i
< pix
->num_planes
; i
++) {
1684 plane_fmt
= &pix
->plane_fmt
[i
];
1685 depth
= fmt
->vpdma_fmt
[i
]->depth
;
1687 stride
= (pix
->width
* fmt
->vpdma_fmt
[VPE_LUMA
]->depth
) >> 3;
1688 if (stride
> plane_fmt
->bytesperline
)
1689 plane_fmt
->bytesperline
= stride
;
1691 plane_fmt
->bytesperline
= ALIGN(plane_fmt
->bytesperline
,
1692 VPDMA_STRIDE_ALIGN
);
1694 if (i
== VPE_LUMA
) {
1695 plane_fmt
->sizeimage
= pix
->height
*
1696 plane_fmt
->bytesperline
;
1698 if (pix
->num_planes
== 1 && fmt
->coplanar
)
1699 plane_fmt
->sizeimage
+= pix
->height
*
1700 plane_fmt
->bytesperline
*
1701 fmt
->vpdma_fmt
[VPE_CHROMA
]->depth
>> 3;
1703 } else { /* i == VIP_CHROMA */
1704 plane_fmt
->sizeimage
= (pix
->height
*
1705 plane_fmt
->bytesperline
*
1708 memset(plane_fmt
->reserved
, 0, sizeof(plane_fmt
->reserved
));
1714 static int vpe_try_fmt(struct file
*file
, void *priv
, struct v4l2_format
*f
)
1716 struct vpe_ctx
*ctx
= file2ctx(file
);
1717 struct vpe_fmt
*fmt
= find_format(f
);
1719 if (V4L2_TYPE_IS_OUTPUT(f
->type
))
1720 return __vpe_try_fmt(ctx
, f
, fmt
, VPE_FMT_TYPE_OUTPUT
);
1722 return __vpe_try_fmt(ctx
, f
, fmt
, VPE_FMT_TYPE_CAPTURE
);
1725 static int __vpe_s_fmt(struct vpe_ctx
*ctx
, struct v4l2_format
*f
)
1727 struct v4l2_pix_format_mplane
*pix
= &f
->fmt
.pix_mp
;
1728 struct v4l2_plane_pix_format
*plane_fmt
;
1729 struct vpe_q_data
*q_data
;
1730 struct vb2_queue
*vq
;
1733 vq
= v4l2_m2m_get_vq(ctx
->fh
.m2m_ctx
, f
->type
);
1737 if (vb2_is_busy(vq
)) {
1738 vpe_err(ctx
->dev
, "queue busy\n");
1742 q_data
= get_q_data(ctx
, f
->type
);
1746 q_data
->fmt
= find_format(f
);
1747 q_data
->width
= pix
->width
;
1748 q_data
->height
= pix
->height
;
1749 q_data
->colorspace
= pix
->colorspace
;
1750 q_data
->field
= pix
->field
;
1751 q_data
->nplanes
= pix
->num_planes
;
1753 for (i
= 0; i
< pix
->num_planes
; i
++) {
1754 plane_fmt
= &pix
->plane_fmt
[i
];
1756 q_data
->bytesperline
[i
] = plane_fmt
->bytesperline
;
1757 q_data
->sizeimage
[i
] = plane_fmt
->sizeimage
;
1760 q_data
->c_rect
.left
= 0;
1761 q_data
->c_rect
.top
= 0;
1762 q_data
->c_rect
.width
= q_data
->width
;
1763 q_data
->c_rect
.height
= q_data
->height
;
1765 if (q_data
->field
== V4L2_FIELD_ALTERNATE
)
1766 q_data
->flags
|= Q_DATA_INTERLACED_ALTERNATE
;
1767 else if (q_data
->field
== V4L2_FIELD_SEQ_TB
)
1768 q_data
->flags
|= Q_DATA_INTERLACED_SEQ_TB
;
1770 q_data
->flags
&= ~Q_IS_INTERLACED
;
1772 /* the crop height is halved for the case of SEQ_TB buffers */
1773 if (q_data
->flags
& Q_DATA_INTERLACED_SEQ_TB
)
1774 q_data
->c_rect
.height
/= 2;
1776 vpe_dbg(ctx
->dev
, "Setting format for type %d, wxh: %dx%d, fmt: %d bpl_y %d",
1777 f
->type
, q_data
->width
, q_data
->height
, q_data
->fmt
->fourcc
,
1778 q_data
->bytesperline
[VPE_LUMA
]);
1779 if (q_data
->nplanes
== 2)
1780 vpe_dbg(ctx
->dev
, " bpl_uv %d\n",
1781 q_data
->bytesperline
[VPE_CHROMA
]);
1786 static int vpe_s_fmt(struct file
*file
, void *priv
, struct v4l2_format
*f
)
1789 struct vpe_ctx
*ctx
= file2ctx(file
);
1791 ret
= vpe_try_fmt(file
, priv
, f
);
1795 ret
= __vpe_s_fmt(ctx
, f
);
1799 if (V4L2_TYPE_IS_OUTPUT(f
->type
))
1800 set_src_registers(ctx
);
1802 set_dst_registers(ctx
);
1804 return set_srcdst_params(ctx
);
1807 static int __vpe_try_selection(struct vpe_ctx
*ctx
, struct v4l2_selection
*s
)
1809 struct vpe_q_data
*q_data
;
1812 if ((s
->type
!= V4L2_BUF_TYPE_VIDEO_CAPTURE
) &&
1813 (s
->type
!= V4L2_BUF_TYPE_VIDEO_OUTPUT
))
1816 q_data
= get_q_data(ctx
, s
->type
);
1820 switch (s
->target
) {
1821 case V4L2_SEL_TGT_COMPOSE
:
1823 * COMPOSE target is only valid for capture buffer type, return
1824 * error for output buffer type
1826 if (s
->type
== V4L2_BUF_TYPE_VIDEO_OUTPUT
)
1829 case V4L2_SEL_TGT_CROP
:
1831 * CROP target is only valid for output buffer type, return
1832 * error for capture buffer type
1834 if (s
->type
== V4L2_BUF_TYPE_VIDEO_CAPTURE
)
1838 * bound and default crop/compose targets are invalid targets to
1846 * For SEQ_TB buffers, crop height should be less than the height of
1847 * the field height, not the buffer height
1849 if (q_data
->flags
& Q_DATA_INTERLACED_SEQ_TB
)
1850 height
= q_data
->height
/ 2;
1852 height
= q_data
->height
;
1854 if (s
->r
.top
< 0 || s
->r
.left
< 0) {
1855 vpe_err(ctx
->dev
, "negative values for top and left\n");
1856 s
->r
.top
= s
->r
.left
= 0;
1859 v4l_bound_align_image(&s
->r
.width
, MIN_W
, q_data
->width
, 1,
1860 &s
->r
.height
, MIN_H
, height
, H_ALIGN
, S_ALIGN
);
1862 /* adjust left/top if cropping rectangle is out of bounds */
1863 if (s
->r
.left
+ s
->r
.width
> q_data
->width
)
1864 s
->r
.left
= q_data
->width
- s
->r
.width
;
1865 if (s
->r
.top
+ s
->r
.height
> q_data
->height
)
1866 s
->r
.top
= q_data
->height
- s
->r
.height
;
1871 static int vpe_g_selection(struct file
*file
, void *fh
,
1872 struct v4l2_selection
*s
)
1874 struct vpe_ctx
*ctx
= file2ctx(file
);
1875 struct vpe_q_data
*q_data
;
1876 bool use_c_rect
= false;
1878 if ((s
->type
!= V4L2_BUF_TYPE_VIDEO_CAPTURE
) &&
1879 (s
->type
!= V4L2_BUF_TYPE_VIDEO_OUTPUT
))
1882 q_data
= get_q_data(ctx
, s
->type
);
1886 switch (s
->target
) {
1887 case V4L2_SEL_TGT_COMPOSE_DEFAULT
:
1888 case V4L2_SEL_TGT_COMPOSE_BOUNDS
:
1889 if (s
->type
== V4L2_BUF_TYPE_VIDEO_OUTPUT
)
1892 case V4L2_SEL_TGT_CROP_BOUNDS
:
1893 case V4L2_SEL_TGT_CROP_DEFAULT
:
1894 if (s
->type
== V4L2_BUF_TYPE_VIDEO_CAPTURE
)
1897 case V4L2_SEL_TGT_COMPOSE
:
1898 if (s
->type
== V4L2_BUF_TYPE_VIDEO_OUTPUT
)
1902 case V4L2_SEL_TGT_CROP
:
1903 if (s
->type
== V4L2_BUF_TYPE_VIDEO_CAPTURE
)
1913 * for CROP/COMPOSE target type, return c_rect params from the
1914 * respective buffer type
1916 s
->r
= q_data
->c_rect
;
1919 * for DEFAULT/BOUNDS target type, return width and height from
1920 * S_FMT of the respective buffer type
1924 s
->r
.width
= q_data
->width
;
1925 s
->r
.height
= q_data
->height
;
1932 static int vpe_s_selection(struct file
*file
, void *fh
,
1933 struct v4l2_selection
*s
)
1935 struct vpe_ctx
*ctx
= file2ctx(file
);
1936 struct vpe_q_data
*q_data
;
1937 struct v4l2_selection sel
= *s
;
1940 ret
= __vpe_try_selection(ctx
, &sel
);
1944 q_data
= get_q_data(ctx
, sel
.type
);
1948 if ((q_data
->c_rect
.left
== sel
.r
.left
) &&
1949 (q_data
->c_rect
.top
== sel
.r
.top
) &&
1950 (q_data
->c_rect
.width
== sel
.r
.width
) &&
1951 (q_data
->c_rect
.height
== sel
.r
.height
)) {
1953 "requested crop/compose values are already set\n");
1957 q_data
->c_rect
= sel
.r
;
1959 return set_srcdst_params(ctx
);
1963 * defines number of buffers/frames a context can process with VPE before
1964 * switching to a different context. default value is 1 buffer per context
1966 #define V4L2_CID_VPE_BUFS_PER_JOB (V4L2_CID_USER_TI_VPE_BASE + 0)
1968 static int vpe_s_ctrl(struct v4l2_ctrl
*ctrl
)
1970 struct vpe_ctx
*ctx
=
1971 container_of(ctrl
->handler
, struct vpe_ctx
, hdl
);
1974 case V4L2_CID_VPE_BUFS_PER_JOB
:
1975 ctx
->bufs_per_job
= ctrl
->val
;
1979 vpe_err(ctx
->dev
, "Invalid control\n");
1986 static const struct v4l2_ctrl_ops vpe_ctrl_ops
= {
1987 .s_ctrl
= vpe_s_ctrl
,
1990 static const struct v4l2_ioctl_ops vpe_ioctl_ops
= {
1991 .vidioc_querycap
= vpe_querycap
,
1993 .vidioc_enum_fmt_vid_cap_mplane
= vpe_enum_fmt
,
1994 .vidioc_g_fmt_vid_cap_mplane
= vpe_g_fmt
,
1995 .vidioc_try_fmt_vid_cap_mplane
= vpe_try_fmt
,
1996 .vidioc_s_fmt_vid_cap_mplane
= vpe_s_fmt
,
1998 .vidioc_enum_fmt_vid_out_mplane
= vpe_enum_fmt
,
1999 .vidioc_g_fmt_vid_out_mplane
= vpe_g_fmt
,
2000 .vidioc_try_fmt_vid_out_mplane
= vpe_try_fmt
,
2001 .vidioc_s_fmt_vid_out_mplane
= vpe_s_fmt
,
2003 .vidioc_g_selection
= vpe_g_selection
,
2004 .vidioc_s_selection
= vpe_s_selection
,
2006 .vidioc_reqbufs
= v4l2_m2m_ioctl_reqbufs
,
2007 .vidioc_querybuf
= v4l2_m2m_ioctl_querybuf
,
2008 .vidioc_qbuf
= v4l2_m2m_ioctl_qbuf
,
2009 .vidioc_dqbuf
= v4l2_m2m_ioctl_dqbuf
,
2010 .vidioc_expbuf
= v4l2_m2m_ioctl_expbuf
,
2011 .vidioc_streamon
= v4l2_m2m_ioctl_streamon
,
2012 .vidioc_streamoff
= v4l2_m2m_ioctl_streamoff
,
2014 .vidioc_subscribe_event
= v4l2_ctrl_subscribe_event
,
2015 .vidioc_unsubscribe_event
= v4l2_event_unsubscribe
,
2021 static int vpe_queue_setup(struct vb2_queue
*vq
,
2022 unsigned int *nbuffers
, unsigned int *nplanes
,
2023 unsigned int sizes
[], struct device
*alloc_devs
[])
2026 struct vpe_ctx
*ctx
= vb2_get_drv_priv(vq
);
2027 struct vpe_q_data
*q_data
;
2029 q_data
= get_q_data(ctx
, vq
->type
);
2031 *nplanes
= q_data
->nplanes
;
2033 for (i
= 0; i
< *nplanes
; i
++)
2034 sizes
[i
] = q_data
->sizeimage
[i
];
2036 vpe_dbg(ctx
->dev
, "get %d buffer(s) of size %d", *nbuffers
,
2038 if (q_data
->nplanes
== 2)
2039 vpe_dbg(ctx
->dev
, " and %d\n", sizes
[VPE_CHROMA
]);
2044 static int vpe_buf_prepare(struct vb2_buffer
*vb
)
2046 struct vb2_v4l2_buffer
*vbuf
= to_vb2_v4l2_buffer(vb
);
2047 struct vpe_ctx
*ctx
= vb2_get_drv_priv(vb
->vb2_queue
);
2048 struct vpe_q_data
*q_data
;
2051 vpe_dbg(ctx
->dev
, "type: %d\n", vb
->vb2_queue
->type
);
2053 q_data
= get_q_data(ctx
, vb
->vb2_queue
->type
);
2054 num_planes
= q_data
->nplanes
;
2056 if (vb
->vb2_queue
->type
== V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE
) {
2057 if (!(q_data
->flags
& Q_IS_INTERLACED
)) {
2058 vbuf
->field
= V4L2_FIELD_NONE
;
2060 if (vbuf
->field
!= V4L2_FIELD_TOP
&&
2061 vbuf
->field
!= V4L2_FIELD_BOTTOM
&&
2062 vbuf
->field
!= V4L2_FIELD_SEQ_TB
)
2067 for (i
= 0; i
< num_planes
; i
++) {
2068 if (vb2_plane_size(vb
, i
) < q_data
->sizeimage
[i
]) {
2070 "data will not fit into plane (%lu < %lu)\n",
2071 vb2_plane_size(vb
, i
),
2072 (long) q_data
->sizeimage
[i
]);
2077 for (i
= 0; i
< num_planes
; i
++)
2078 vb2_set_plane_payload(vb
, i
, q_data
->sizeimage
[i
]);
2083 static void vpe_buf_queue(struct vb2_buffer
*vb
)
2085 struct vb2_v4l2_buffer
*vbuf
= to_vb2_v4l2_buffer(vb
);
2086 struct vpe_ctx
*ctx
= vb2_get_drv_priv(vb
->vb2_queue
);
2088 v4l2_m2m_buf_queue(ctx
->fh
.m2m_ctx
, vbuf
);
2091 static int check_srcdst_sizes(struct vpe_ctx
*ctx
)
2093 struct vpe_q_data
*s_q_data
= &ctx
->q_data
[Q_DATA_SRC
];
2094 struct vpe_q_data
*d_q_data
= &ctx
->q_data
[Q_DATA_DST
];
2095 unsigned int src_w
= s_q_data
->c_rect
.width
;
2096 unsigned int src_h
= s_q_data
->c_rect
.height
;
2097 unsigned int dst_w
= d_q_data
->c_rect
.width
;
2098 unsigned int dst_h
= d_q_data
->c_rect
.height
;
2100 if (src_w
== dst_w
&& src_h
== dst_h
)
2103 if (src_h
<= SC_MAX_PIXEL_HEIGHT
&&
2104 src_w
<= SC_MAX_PIXEL_WIDTH
&&
2105 dst_h
<= SC_MAX_PIXEL_HEIGHT
&&
2106 dst_w
<= SC_MAX_PIXEL_WIDTH
)
2112 static void vpe_return_all_buffers(struct vpe_ctx
*ctx
, struct vb2_queue
*q
,
2113 enum vb2_buffer_state state
)
2115 struct vb2_v4l2_buffer
*vb
;
2116 unsigned long flags
;
2119 if (V4L2_TYPE_IS_OUTPUT(q
->type
))
2120 vb
= v4l2_m2m_src_buf_remove(ctx
->fh
.m2m_ctx
);
2122 vb
= v4l2_m2m_dst_buf_remove(ctx
->fh
.m2m_ctx
);
2125 spin_lock_irqsave(&ctx
->dev
->lock
, flags
);
2126 v4l2_m2m_buf_done(vb
, state
);
2127 spin_unlock_irqrestore(&ctx
->dev
->lock
, flags
);
2131 * Cleanup the in-transit vb2 buffers that have been
2132 * removed from their respective queue already but for
2133 * which procecessing has not been completed yet.
2135 if (V4L2_TYPE_IS_OUTPUT(q
->type
)) {
2136 spin_lock_irqsave(&ctx
->dev
->lock
, flags
);
2138 if (ctx
->src_vbs
[2])
2139 v4l2_m2m_buf_done(ctx
->src_vbs
[2], state
);
2141 if (ctx
->src_vbs
[1] && (ctx
->src_vbs
[1] != ctx
->src_vbs
[2]))
2142 v4l2_m2m_buf_done(ctx
->src_vbs
[1], state
);
2144 if (ctx
->src_vbs
[0] &&
2145 (ctx
->src_vbs
[0] != ctx
->src_vbs
[1]) &&
2146 (ctx
->src_vbs
[0] != ctx
->src_vbs
[2]))
2147 v4l2_m2m_buf_done(ctx
->src_vbs
[0], state
);
2149 ctx
->src_vbs
[2] = NULL
;
2150 ctx
->src_vbs
[1] = NULL
;
2151 ctx
->src_vbs
[0] = NULL
;
2153 spin_unlock_irqrestore(&ctx
->dev
->lock
, flags
);
2156 spin_lock_irqsave(&ctx
->dev
->lock
, flags
);
2158 v4l2_m2m_buf_done(ctx
->dst_vb
, state
);
2160 spin_unlock_irqrestore(&ctx
->dev
->lock
, flags
);
2165 static int vpe_start_streaming(struct vb2_queue
*q
, unsigned int count
)
2167 struct vpe_ctx
*ctx
= vb2_get_drv_priv(q
);
2169 /* Check any of the size exceed maximum scaling sizes */
2170 if (check_srcdst_sizes(ctx
)) {
2172 "Conversion setup failed, check source and destination parameters\n"
2174 vpe_return_all_buffers(ctx
, q
, VB2_BUF_STATE_QUEUED
);
2178 if (ctx
->deinterlacing
)
2179 config_edi_input_mode(ctx
, 0x0);
2181 if (ctx
->sequence
!= 0)
2182 set_srcdst_params(ctx
);
2187 static void vpe_stop_streaming(struct vb2_queue
*q
)
2189 struct vpe_ctx
*ctx
= vb2_get_drv_priv(q
);
2191 vpe_dump_regs(ctx
->dev
);
2192 vpdma_dump_regs(ctx
->dev
->vpdma
);
2194 vpe_return_all_buffers(ctx
, q
, VB2_BUF_STATE_ERROR
);
2197 static const struct vb2_ops vpe_qops
= {
2198 .queue_setup
= vpe_queue_setup
,
2199 .buf_prepare
= vpe_buf_prepare
,
2200 .buf_queue
= vpe_buf_queue
,
2201 .wait_prepare
= vb2_ops_wait_prepare
,
2202 .wait_finish
= vb2_ops_wait_finish
,
2203 .start_streaming
= vpe_start_streaming
,
2204 .stop_streaming
= vpe_stop_streaming
,
2207 static int queue_init(void *priv
, struct vb2_queue
*src_vq
,
2208 struct vb2_queue
*dst_vq
)
2210 struct vpe_ctx
*ctx
= priv
;
2211 struct vpe_dev
*dev
= ctx
->dev
;
2214 memset(src_vq
, 0, sizeof(*src_vq
));
2215 src_vq
->type
= V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE
;
2216 src_vq
->io_modes
= VB2_MMAP
| VB2_DMABUF
;
2217 src_vq
->drv_priv
= ctx
;
2218 src_vq
->buf_struct_size
= sizeof(struct v4l2_m2m_buffer
);
2219 src_vq
->ops
= &vpe_qops
;
2220 src_vq
->mem_ops
= &vb2_dma_contig_memops
;
2221 src_vq
->timestamp_flags
= V4L2_BUF_FLAG_TIMESTAMP_COPY
;
2222 src_vq
->lock
= &dev
->dev_mutex
;
2223 src_vq
->dev
= dev
->v4l2_dev
.dev
;
2225 ret
= vb2_queue_init(src_vq
);
2229 memset(dst_vq
, 0, sizeof(*dst_vq
));
2230 dst_vq
->type
= V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE
;
2231 dst_vq
->io_modes
= VB2_MMAP
| VB2_DMABUF
;
2232 dst_vq
->drv_priv
= ctx
;
2233 dst_vq
->buf_struct_size
= sizeof(struct v4l2_m2m_buffer
);
2234 dst_vq
->ops
= &vpe_qops
;
2235 dst_vq
->mem_ops
= &vb2_dma_contig_memops
;
2236 dst_vq
->timestamp_flags
= V4L2_BUF_FLAG_TIMESTAMP_COPY
;
2237 dst_vq
->lock
= &dev
->dev_mutex
;
2238 dst_vq
->dev
= dev
->v4l2_dev
.dev
;
2240 return vb2_queue_init(dst_vq
);
2243 static const struct v4l2_ctrl_config vpe_bufs_per_job
= {
2244 .ops
= &vpe_ctrl_ops
,
2245 .id
= V4L2_CID_VPE_BUFS_PER_JOB
,
2246 .name
= "Buffers Per Transaction",
2247 .type
= V4L2_CTRL_TYPE_INTEGER
,
2248 .def
= VPE_DEF_BUFS_PER_JOB
,
2250 .max
= VIDEO_MAX_FRAME
,
2257 static int vpe_open(struct file
*file
)
2259 struct vpe_dev
*dev
= video_drvdata(file
);
2260 struct vpe_q_data
*s_q_data
;
2261 struct v4l2_ctrl_handler
*hdl
;
2262 struct vpe_ctx
*ctx
;
2265 vpe_dbg(dev
, "vpe_open\n");
2267 ctx
= kzalloc(sizeof(*ctx
), GFP_KERNEL
);
2273 if (mutex_lock_interruptible(&dev
->dev_mutex
)) {
2278 ret
= vpdma_create_desc_list(&ctx
->desc_list
, VPE_DESC_LIST_SIZE
,
2279 VPDMA_LIST_TYPE_NORMAL
);
2283 ret
= vpdma_alloc_desc_buf(&ctx
->mmr_adb
, sizeof(struct vpe_mmr_adb
));
2285 goto free_desc_list
;
2287 ret
= vpdma_alloc_desc_buf(&ctx
->sc_coeff_h
, SC_COEF_SRAM_SIZE
);
2291 ret
= vpdma_alloc_desc_buf(&ctx
->sc_coeff_v
, SC_COEF_SRAM_SIZE
);
2297 v4l2_fh_init(&ctx
->fh
, video_devdata(file
));
2298 file
->private_data
= &ctx
->fh
;
2301 v4l2_ctrl_handler_init(hdl
, 1);
2302 v4l2_ctrl_new_custom(hdl
, &vpe_bufs_per_job
, NULL
);
2307 ctx
->fh
.ctrl_handler
= hdl
;
2308 v4l2_ctrl_handler_setup(hdl
);
2310 s_q_data
= &ctx
->q_data
[Q_DATA_SRC
];
2311 s_q_data
->fmt
= &vpe_formats
[2];
2312 s_q_data
->width
= 1920;
2313 s_q_data
->height
= 1080;
2314 s_q_data
->nplanes
= 1;
2315 s_q_data
->bytesperline
[VPE_LUMA
] = (s_q_data
->width
*
2316 s_q_data
->fmt
->vpdma_fmt
[VPE_LUMA
]->depth
) >> 3;
2317 s_q_data
->sizeimage
[VPE_LUMA
] = (s_q_data
->bytesperline
[VPE_LUMA
] *
2319 s_q_data
->colorspace
= V4L2_COLORSPACE_REC709
;
2320 s_q_data
->field
= V4L2_FIELD_NONE
;
2321 s_q_data
->c_rect
.left
= 0;
2322 s_q_data
->c_rect
.top
= 0;
2323 s_q_data
->c_rect
.width
= s_q_data
->width
;
2324 s_q_data
->c_rect
.height
= s_q_data
->height
;
2325 s_q_data
->flags
= 0;
2327 ctx
->q_data
[Q_DATA_DST
] = *s_q_data
;
2329 set_dei_shadow_registers(ctx
);
2330 set_src_registers(ctx
);
2331 set_dst_registers(ctx
);
2332 ret
= set_srcdst_params(ctx
);
2336 ctx
->fh
.m2m_ctx
= v4l2_m2m_ctx_init(dev
->m2m_dev
, ctx
, &queue_init
);
2338 if (IS_ERR(ctx
->fh
.m2m_ctx
)) {
2339 ret
= PTR_ERR(ctx
->fh
.m2m_ctx
);
2343 v4l2_fh_add(&ctx
->fh
);
2346 * for now, just report the creation of the first instance, we can later
2347 * optimize the driver to enable or disable clocks when the first
2348 * instance is created or the last instance released
2350 if (atomic_inc_return(&dev
->num_instances
) == 1)
2351 vpe_dbg(dev
, "first instance created\n");
2353 ctx
->bufs_per_job
= VPE_DEF_BUFS_PER_JOB
;
2355 ctx
->load_mmrs
= true;
2357 vpe_dbg(dev
, "created instance %p, m2m_ctx: %p\n",
2358 ctx
, ctx
->fh
.m2m_ctx
);
2360 mutex_unlock(&dev
->dev_mutex
);
2364 v4l2_ctrl_handler_free(hdl
);
2365 v4l2_fh_exit(&ctx
->fh
);
2366 vpdma_free_desc_buf(&ctx
->sc_coeff_v
);
2368 vpdma_free_desc_buf(&ctx
->sc_coeff_h
);
2370 vpdma_free_desc_buf(&ctx
->mmr_adb
);
2372 vpdma_free_desc_list(&ctx
->desc_list
);
2374 mutex_unlock(&dev
->dev_mutex
);
2380 static int vpe_release(struct file
*file
)
2382 struct vpe_dev
*dev
= video_drvdata(file
);
2383 struct vpe_ctx
*ctx
= file2ctx(file
);
2385 vpe_dbg(dev
, "releasing instance %p\n", ctx
);
2387 mutex_lock(&dev
->dev_mutex
);
2388 free_mv_buffers(ctx
);
2389 vpdma_free_desc_list(&ctx
->desc_list
);
2390 vpdma_free_desc_buf(&ctx
->mmr_adb
);
2392 vpdma_free_desc_buf(&ctx
->sc_coeff_v
);
2393 vpdma_free_desc_buf(&ctx
->sc_coeff_h
);
2395 v4l2_fh_del(&ctx
->fh
);
2396 v4l2_fh_exit(&ctx
->fh
);
2397 v4l2_ctrl_handler_free(&ctx
->hdl
);
2398 v4l2_m2m_ctx_release(ctx
->fh
.m2m_ctx
);
2403 * for now, just report the release of the last instance, we can later
2404 * optimize the driver to enable or disable clocks when the first
2405 * instance is created or the last instance released
2407 if (atomic_dec_return(&dev
->num_instances
) == 0)
2408 vpe_dbg(dev
, "last instance released\n");
2410 mutex_unlock(&dev
->dev_mutex
);
2415 static const struct v4l2_file_operations vpe_fops
= {
2416 .owner
= THIS_MODULE
,
2418 .release
= vpe_release
,
2419 .poll
= v4l2_m2m_fop_poll
,
2420 .unlocked_ioctl
= video_ioctl2
,
2421 .mmap
= v4l2_m2m_fop_mmap
,
2424 static const struct video_device vpe_videodev
= {
2425 .name
= VPE_MODULE_NAME
,
2427 .ioctl_ops
= &vpe_ioctl_ops
,
2429 .release
= video_device_release_empty
,
2430 .vfl_dir
= VFL_DIR_M2M
,
2433 static const struct v4l2_m2m_ops m2m_ops
= {
2434 .device_run
= device_run
,
2435 .job_ready
= job_ready
,
2436 .job_abort
= job_abort
,
2438 .unlock
= vpe_unlock
,
2441 static int vpe_runtime_get(struct platform_device
*pdev
)
2445 dev_dbg(&pdev
->dev
, "vpe_runtime_get\n");
2447 r
= pm_runtime_get_sync(&pdev
->dev
);
2449 return r
< 0 ? r
: 0;
2452 static void vpe_runtime_put(struct platform_device
*pdev
)
2457 dev_dbg(&pdev
->dev
, "vpe_runtime_put\n");
2459 r
= pm_runtime_put_sync(&pdev
->dev
);
2460 WARN_ON(r
< 0 && r
!= -ENOSYS
);
2463 static void vpe_fw_cb(struct platform_device
*pdev
)
2465 struct vpe_dev
*dev
= platform_get_drvdata(pdev
);
2466 struct video_device
*vfd
;
2470 *vfd
= vpe_videodev
;
2471 vfd
->lock
= &dev
->dev_mutex
;
2472 vfd
->v4l2_dev
= &dev
->v4l2_dev
;
2474 ret
= video_register_device(vfd
, VFL_TYPE_GRABBER
, 0);
2476 vpe_err(dev
, "Failed to register video device\n");
2478 vpe_set_clock_enable(dev
, 0);
2479 vpe_runtime_put(pdev
);
2480 pm_runtime_disable(&pdev
->dev
);
2481 v4l2_m2m_release(dev
->m2m_dev
);
2482 v4l2_device_unregister(&dev
->v4l2_dev
);
2487 video_set_drvdata(vfd
, dev
);
2488 snprintf(vfd
->name
, sizeof(vfd
->name
), "%s", vpe_videodev
.name
);
2489 dev_info(dev
->v4l2_dev
.dev
, "Device registered as /dev/video%d\n",
2493 static int vpe_probe(struct platform_device
*pdev
)
2495 struct vpe_dev
*dev
;
2498 dev
= devm_kzalloc(&pdev
->dev
, sizeof(*dev
), GFP_KERNEL
);
2502 spin_lock_init(&dev
->lock
);
2504 ret
= v4l2_device_register(&pdev
->dev
, &dev
->v4l2_dev
);
2508 atomic_set(&dev
->num_instances
, 0);
2509 mutex_init(&dev
->dev_mutex
);
2511 dev
->res
= platform_get_resource_byname(pdev
, IORESOURCE_MEM
,
2514 * HACK: we get resource info from device tree in the form of a list of
2515 * VPE sub blocks, the driver currently uses only the base of vpe_top
2516 * for register access, the driver should be changed later to access
2517 * registers based on the sub block base addresses
2519 dev
->base
= devm_ioremap(&pdev
->dev
, dev
->res
->start
, SZ_32K
);
2522 goto v4l2_dev_unreg
;
2525 irq
= platform_get_irq(pdev
, 0);
2526 ret
= devm_request_irq(&pdev
->dev
, irq
, vpe_irq
, 0, VPE_MODULE_NAME
,
2529 goto v4l2_dev_unreg
;
2531 platform_set_drvdata(pdev
, dev
);
2533 dev
->m2m_dev
= v4l2_m2m_init(&m2m_ops
);
2534 if (IS_ERR(dev
->m2m_dev
)) {
2535 vpe_err(dev
, "Failed to init mem2mem device\n");
2536 ret
= PTR_ERR(dev
->m2m_dev
);
2537 goto v4l2_dev_unreg
;
2540 pm_runtime_enable(&pdev
->dev
);
2542 ret
= vpe_runtime_get(pdev
);
2546 /* Perform clk enable followed by reset */
2547 vpe_set_clock_enable(dev
, 1);
2551 func
= read_field_reg(dev
, VPE_PID
, VPE_PID_FUNC_MASK
,
2552 VPE_PID_FUNC_SHIFT
);
2553 vpe_dbg(dev
, "VPE PID function %x\n", func
);
2555 vpe_top_vpdma_reset(dev
);
2557 dev
->sc
= sc_create(pdev
, "sc");
2558 if (IS_ERR(dev
->sc
)) {
2559 ret
= PTR_ERR(dev
->sc
);
2563 dev
->csc
= csc_create(pdev
, "csc");
2564 if (IS_ERR(dev
->csc
)) {
2565 ret
= PTR_ERR(dev
->csc
);
2569 dev
->vpdma
= &dev
->vpdma_data
;
2570 ret
= vpdma_create(pdev
, dev
->vpdma
, vpe_fw_cb
);
2577 vpe_runtime_put(pdev
);
2579 pm_runtime_disable(&pdev
->dev
);
2580 v4l2_m2m_release(dev
->m2m_dev
);
2582 v4l2_device_unregister(&dev
->v4l2_dev
);
2587 static int vpe_remove(struct platform_device
*pdev
)
2589 struct vpe_dev
*dev
= platform_get_drvdata(pdev
);
2591 v4l2_info(&dev
->v4l2_dev
, "Removing " VPE_MODULE_NAME
);
2593 v4l2_m2m_release(dev
->m2m_dev
);
2594 video_unregister_device(&dev
->vfd
);
2595 v4l2_device_unregister(&dev
->v4l2_dev
);
2597 vpe_set_clock_enable(dev
, 0);
2598 vpe_runtime_put(pdev
);
2599 pm_runtime_disable(&pdev
->dev
);
2604 #if defined(CONFIG_OF)
2605 static const struct of_device_id vpe_of_match
[] = {
2607 .compatible
= "ti,vpe",
2611 MODULE_DEVICE_TABLE(of
, vpe_of_match
);
2614 static struct platform_driver vpe_pdrv
= {
2616 .remove
= vpe_remove
,
2618 .name
= VPE_MODULE_NAME
,
2619 .of_match_table
= of_match_ptr(vpe_of_match
),
2623 module_platform_driver(vpe_pdrv
);
2625 MODULE_DESCRIPTION("TI VPE driver");
2626 MODULE_AUTHOR("Dale Farnsworth, <dale@farnsworth.org>");
2627 MODULE_LICENSE("GPL");