Add support for mt2701 JPEG ENC support
Subsystems (3)
v6 cover Add support for mt2701 JPEG ENC support
This patchset add support for mt2701 JPEG ENC support.
This is the compliance test result for jpeg dec and enc.
The JPEG dec log:
------------------------------------------------------------
v4l2-compliance -d /dev/video0
v4l2-compliance SHA: af33cc5ef00177edbb45d466faf9061197767f2b, 32 bits
Compliance test for mtk-jpeg device /dev/video0:
Driver Info:
Driver name : mtk-jpeg
Card type : mtk-jpeg decoder
Bus info : platform:15004000.jpegdec
Driver version : 5.5.0
Capabilities : 0x84204000 Video Memory-to-Memory Multiplanar Streaming
Extended Pix Format
Device Capabilities
Device Caps : 0x04204000
Video Memory-to-Memory Multiplanar Streaming
Extended Pix Format
Detected JPEG Decoder
Required ioctls:
test VIDIOC_QUERYCAP: OK
Allow for multiple opens:
test second /dev/video0 open: OK
test VIDIOC_QUERYCAP: OK
test VIDIOC_G/S_PRIORITY: OK
test for unlimited opens: OK
Debug ioctls:
test VIDIOC_DBG_G/S_REGISTER: OK (Not Supported) test VIDIOC_LOG_STATUS: OK (Not Supported)
Input ioctls:
test VIDIOC_G/S_TUNER/ENUM_FREQ_BANDS: OK (Not Supported) test VIDIOC_G/S_FREQUENCY: OK (Not Supported) test VIDIOC_S_HW_FREQ_SEEK: OK (Not Supported) test VIDIOC_ENUMAUDIO: OK (Not Supported)
test VIDIOC_G/S/ENUMINPUT: OK (Not Supported) test VIDIOC_G/S_AUDIO: OK (Not Supported)
Inputs: 0 Audio Inputs: 0 Tuners: 0
Output ioctls:
test VIDIOC_G/S_MODULATOR: OK (Not Supported) test VIDIOC_G/S_FREQUENCY: OK (Not Supported) test VIDIOC_ENUMAUDOUT: OK (Not Supported) test VIDIOC_G/S/ENUMOUTPUT: OK (Not Supported) test VIDIOC_G/S_AUDOUT: OK (Not Supported)
Outputs: 0 Audio Outputs: 0 Modulators: 0
Input/Output configuration ioctls:
test VIDIOC_ENUM/G/S/QUERY_STD: OK (Not Supported) test VIDIOC_ENUM/G/S/QUERY_DV_TIMINGS: OK (Not Supported) test VIDIOC_DV_TIMINGS_CAP: OK (Not Supported) test VIDIOC_G/S_EDID: OK (Not Supported)
Control ioctls:
test VIDIOC_QUERY_EXT_CTRL/QUERYMENU: OK
test VIDIOC_QUERYCTRL: OK
test VIDIOC_G/S_CTRL: OK
test VIDIOC_G/S/TRY_EXT_CTRLS: OK
test VIDIOC_(UN)SUBSCRIBE_EVENT/DQEVENT: OK (Not Supported) test VIDIOC_G/S_JPEGCOMP: OK (Not Supported) Standard Controls: 0 Private Controls: 0
Format ioctls:
test VIDIOC_ENUM_FMT/FRAMESIZES/FRAMEINTERVALS: OK test VIDIOC_G/S_PARM: OK (Not Supported) test VIDIOC_G_FBUF: OK (Not Supported) test VIDIOC_G_FMT: OK
test VIDIOC_TRY_FMT: OK
test VIDIOC_S_FMT: OK
test VIDIOC_G_SLICED_VBI_CAP: OK (Not Supported) test Cropping: OK (Not Supported)
test Composing: OK
test Scaling: OK
Codec ioctls:
test VIDIOC_(TRY_)ENCODER_CMD: OK (Not Supported) test VIDIOC_G_ENC_INDEX: OK (Not Supported) test VIDIOC_(TRY_)DECODER_CMD: OK (Not Supported)
Buffer ioctls:
test VIDIOC_REQBUFS/CREATE_BUFS/QUERYBUF: OK test VIDIOC_EXPBUF: OK
test Requests: OK (Not Supported)
Total for mtk-jpeg device /dev/video0: 44, Succeeded: 44, Failed: 0, Warnings: 0
------------------------------------------------------------
The JPEG enc log:
------------------------------------------------------------
v4l2-compliance -d /dev/video1
v4l2-compliance SHA: af33cc5ef00177edbb45d466faf9061197767f2b, 32 bits
Compliance test for mtk-jpeg device /dev/video1:
Driver Info:
Driver name : mtk-jpeg
Card type : mtk-jpeg encoder
Bus info : platform:1500a000.jpegenc
Driver version : 5.5.0
Capabilities : 0x84204000 Video Memory-to-Memory Multiplanar Streaming
Extended Pix Format
Device Capabilities
Device Caps : 0x04204000
Video Memory-to-Memory Multiplanar Streaming
Extended Pix Format
Detected JPEG Encoder
Required ioctls:
test VIDIOC_QUERYCAP: OK
Allow for multiple opens:
test second /dev/video1 open: OK
test VIDIOC_QUERYCAP: OK
test VIDIOC_G/S_PRIORITY: OK
test for unlimited opens: OK
Debug ioctls:
test VIDIOC_DBG_G/S_REGISTER: OK (Not Supported) test VIDIOC_LOG_STATUS: OK (Not Supported)
Input ioctls:
test VIDIOC_G/S_TUNER/ENUM_FREQ_BANDS: OK (Not Supported) test VIDIOC_G/S_FREQUENCY: OK (Not Supported) test VIDIOC_S_HW_FREQ_SEEK: OK (Not Supported) test VIDIOC_ENUMAUDIO: OK (Not Supported)
test VIDIOC_G/S/ENUMINPUT: OK (Not Supported) test VIDIOC_G/S_AUDIO: OK (Not Supported)
Inputs: 0 Audio Inputs: 0 Tuners: 0
Output ioctls:
test VIDIOC_G/S_MODULATOR: OK (Not Supported) test VIDIOC_G/S_FREQUENCY: OK (Not Supported) test VIDIOC_ENUMAUDOUT: OK (Not Supported) test VIDIOC_G/S/ENUMOUTPUT: OK (Not Supported) test VIDIOC_G/S_AUDOUT: OK (Not Supported)
Outputs: 0 Audio Outputs: 0 Modulators: 0
Input/Output configuration ioctls:
test VIDIOC_ENUM/G/S/QUERY_STD: OK (Not Supported) test VIDIOC_ENUM/G/S/QUERY_DV_TIMINGS: OK (Not Supported) test VIDIOC_DV_TIMINGS_CAP: OK (Not Supported) test VIDIOC_G/S_EDID: OK (Not Supported)
Control ioctls:
test VIDIOC_QUERY_EXT_CTRL/QUERYMENU: OK test VIDIOC_QUERYCTRL: OK
test VIDIOC_G/S_CTRL: OK
test VIDIOC_G/S/TRY_EXT_CTRLS: OK test VIDIOC_(UN)SUBSCRIBE_EVENT/DQEVENT: OK test VIDIOC_G/S_JPEGCOMP: OK (Not Supported) Standard Controls: 4 Private Controls: 0
Format ioctls:
test VIDIOC_ENUM_FMT/FRAMESIZES/FRAMEINTERVALS: OK test VIDIOC_G/S_PARM: OK (Not Supported) test VIDIOC_G_FBUF: OK (Not Supported) test VIDIOC_G_FMT: OK
test VIDIOC_TRY_FMT: OK
test VIDIOC_S_FMT: OK
test VIDIOC_G_SLICED_VBI_CAP: OK (Not Supported) test Cropping: OK
test Composing: OK (Not Supported)
test Scaling: OK (Not Supported)
Codec ioctls:
test VIDIOC_(TRY_)ENCODER_CMD: OK (Not Supported) test VIDIOC_G_ENC_INDEX: OK (Not Supported) test VIDIOC_(TRY_)DECODER_CMD: OK (Not Supported)
Buffer ioctls:
test VIDIOC_REQBUFS/CREATE_BUFS/QUERYBUF: OK test VIDIOC_EXPBUF: OK
test Requests: OK (Not Supported)
Total for mtk-jpeg device /dev/video1: 44, Succeeded: 44, Failed: 0, Warnings: 0
------------------------------------------------------------
Change compared to v5:
-fix checkpatch, compiler and sparse/smatch warnings.
Xia Jiang (5):
media: platform: Fix jpeg dec driver bug and improve code quality
media: dt-bindings: Add jpeg enc device tree node document
arm: dts: Add jpeg enc device tree node
media: platform: Rename jpeg dec file name
media: platform: Add jpeg dec/enc feature
.../bindings/media/mediatek-jpeg-encoder.txt | 37 +
arch/arm/boot/dts/mt2701.dtsi | 13 +
drivers/media/platform/mtk-jpeg/Makefile | 5 +-
.../media/platform/mtk-jpeg/mtk_jpeg_core.c | 757 +++++++++++++-----
.../media/platform/mtk-jpeg/mtk_jpeg_core.h | 50 +-
.../{mtk_jpeg_hw.c => mtk_jpeg_dec_hw.c} | 10 +-
.../{mtk_jpeg_hw.h => mtk_jpeg_dec_hw.h} | 14 +-
...{mtk_jpeg_parse.c => mtk_jpeg_dec_parse.c} | 2 +-
...{mtk_jpeg_parse.h => mtk_jpeg_dec_parse.h} | 2 +-
.../{mtk_jpeg_reg.h => mtk_jpeg_dec_reg.h} | 19 +-
.../media/platform/mtk-jpeg/mtk_jpeg_enc_hw.c | 273 +++++++
.../media/platform/mtk-jpeg/mtk_jpeg_enc_hw.h | 86 ++
.../platform/mtk-jpeg/mtk_jpeg_enc_reg.h | 78 ++
13 files changed, 1104 insertions(+), 242 deletions(-)
create mode 100644 Documentation/devicetree/bindings/media/mediatek-jpeg-encoder.txt
rename drivers/media/platform/mtk-jpeg/{mtk_jpeg_hw.c => mtk_jpeg_dec_hw.c} (98%)
rename drivers/media/platform/mtk-jpeg/{mtk_jpeg_hw.h => mtk_jpeg_dec_hw.h} (89%)
rename drivers/media/platform/mtk-jpeg/{mtk_jpeg_parse.c => mtk_jpeg_dec_parse.c} (98%)
rename drivers/media/platform/mtk-jpeg/{mtk_jpeg_parse.h => mtk_jpeg_dec_parse.h} (92%)
rename drivers/media/platform/mtk-jpeg/{mtk_jpeg_reg.h => mtk_jpeg_dec_reg.h} (77%)
create mode 100644 drivers/media/platform/mtk-jpeg/mtk_jpeg_enc_hw.c
create mode 100644 drivers/media/platform/mtk-jpeg/mtk_jpeg_enc_hw.h
create mode 100644 drivers/media/platform/mtk-jpeg/mtk_jpeg_enc_reg.hSignature · 6 lines
2.18.0 _______________________________________________ linux-arm-kernel mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
PATCH v6 1/5 media: platform: Fix jpeg dec driver bug and improve code quality
Fix v4l2-compliance test bug and improve code quality of jpeg decode driver, because the jpeg encode driver will base on it.
---
v6: alignment 'MTK_JPEG_DCTSIZE' match open parenthesis.
v5: Use clamp()to replace mtk_jpeg_bound_align_image() and round_up()
to replace mtk_jpeg_align().
Get correct compose value in mtk_jpeg_selection(). Cancel spin lock and unlock operation in device run function. Change register offset hex numberals from upercase to lowercase.
v4: new add patch for v4l2-compliance test bug fix.
--- .../media/platform/mtk-jpeg/mtk_jpeg_core.c | 76 ++++++------------- .../media/platform/mtk-jpeg/mtk_jpeg_core.h | 7 +- drivers/media/platform/mtk-jpeg/mtk_jpeg_hw.c | 8 +- drivers/media/platform/mtk-jpeg/mtk_jpeg_hw.h | 5 -- .../media/platform/mtk-jpeg/mtk_jpeg_reg.h | 19 +++-- 5 files changed, 43 insertions(+), 72 deletions(-)
drivers/media/platform/mtk-jpeg/mtk_jpeg_core.c +25 -51
@@ -157,25 +157,6 @@ static struct mtk_jpeg_fmt *mtk_jpeg_find_format(struct mtk_jpeg_ctx *ctx,return NULL ; } -static void mtk_jpeg_bound_align_image (u32 *w,unsigned int wmin, -unsigned int wmax,unsigned int walign, -u32 *h,unsigned int hmin, -unsigned int hmax,unsigned int halign) -{ -int width, height, w_step, h_step; - - width = *w; - height = *h; - w_step =1 << walign; - h_step =1 << halign; - -v4l_bound_align_image (w, wmin, wmax, walign, h, hmin, hmax, halign,0 ); -if (*w < width && (*w + w_step) <= wmax) - *w += w_step; -if (*h < height && (*h + h_step) <= hmax) - *h += h_step; -} -static void mtk_jpeg_adjust_fmt_mplane (struct mtk_jpeg_ctx *ctx,struct v4l2_format *f) {
@@ -201,7 +182,6 @@ static int mtk_jpeg_try_fmt_mplane(struct v4l2_format *f, struct mtk_jpeg_ctx *ctx, int q_type) {struct v4l2_pix_format_mplane *pix_mp = &f->fmt.pix_mp; -struct mtk_jpeg_dev *jpeg = ctx->jpeg;int i;memset (pix_mp->reserved,0 ,sizeof (pix_mp->reserved));
@@ -209,7 +189,7 @@ static int mtk_jpeg_try_fmt_mplane(struct v4l2_format *f,if (ctx->state !=MTK_JPEG_INIT ) {mtk_jpeg_adjust_fmt_mplane (ctx, f); - goto end; +return 0 ; } pix_mp->num_planes = fmt->colplanes;
@@ -218,45 +198,35 @@ static int mtk_jpeg_try_fmt_mplane(struct v4l2_format *f,if (q_type ==MTK_JPEG_FMT_TYPE_OUTPUT ) {struct v4l2_plane_pix_format *pfmt = &pix_mp->plane_fmt[0 ]; -mtk_jpeg_bound_align_image (&pix_mp->width,MTK_JPEG_MIN_WIDTH , -MTK_JPEG_MAX_WIDTH ,0 , - &pix_mp->height,MTK_JPEG_MIN_HEIGHT , -MTK_JPEG_MAX_HEIGHT ,0 ); + pix_mp->height =clamp (pix_mp->height,MTK_JPEG_MIN_HEIGHT , +MTK_JPEG_MAX_HEIGHT ); + pix_mp->width =clamp (pix_mp->width,MTK_JPEG_MIN_WIDTH , +MTK_JPEG_MAX_WIDTH );memset (pfmt->reserved,0 ,sizeof (pfmt->reserved)); pfmt->bytesperline =0 ;/* Source size must be aligned to 128 */ - pfmt->sizeimage =mtk_jpeg_align (pfmt->sizeimage,128 ); + pfmt->sizeimage =round_up (pfmt->sizeimage,128 );if (pfmt->sizeimage ==0 ) pfmt->sizeimage =MTK_JPEG_DEFAULT_SIZEIMAGE ; - goto end; +return 0 ; }/* type is MTK_JPEG_FMT_TYPE_CAPTURE */ -mtk_jpeg_bound_align_image (&pix_mp->width,MTK_JPEG_MIN_WIDTH , -MTK_JPEG_MAX_WIDTH , fmt->h_align, - &pix_mp->height,MTK_JPEG_MIN_HEIGHT , -MTK_JPEG_MAX_HEIGHT , fmt->v_align); + pix_mp->height =clamp (round_up (pix_mp->height, fmt->v_align), +MTK_JPEG_MIN_HEIGHT ,MTK_JPEG_MAX_HEIGHT ); + pix_mp->width =clamp (round_up (pix_mp->width, fmt->h_align), +MTK_JPEG_MIN_WIDTH ,MTK_JPEG_MAX_WIDTH );for (i =0 ; i < fmt->colplanes; i++) {struct v4l2_plane_pix_format *pfmt = &pix_mp->plane_fmt[i];u32 stride = pix_mp->width * fmt->h_sample[i] /4 ;u32 h = pix_mp->height * fmt->v_sample[i] /4 ; -memset (pfmt->reserved,0 ,sizeof (pfmt->reserved)); pfmt->bytesperline = stride; pfmt->sizeimage = stride * h; } -end: -v4l2_dbg (2 , debug, &jpeg->v4l2_dev,"wxh:%ux%u\n" , - pix_mp->width, pix_mp->height); -for (i =0 ; i < pix_mp->num_planes; i++) { -v4l2_dbg (2 , debug, &jpeg->v4l2_dev, -"plane[%d] bpl=%u, size=%u\n" , - i, - pix_mp->plane_fmt[i].bytesperline, - pix_mp->plane_fmt[i].sizeimage); - } +return 0 ; }
@@ -446,9 +416,9 @@ static int mtk_jpeg_subscribe_event(struct v4l2_fh *fh,switch (sub->type) {case V4L2_EVENT_SOURCE_CHANGE :return v4l2_src_change_event_subscribe (fh, sub); -default : -return -EINVAL ; } + +return v4l2_ctrl_subscribe_event (fh, sub); } static int mtk_jpeg_g_selection(struct file *file, void *priv,
@@ -492,8 +462,8 @@ static int mtk_jpeg_s_selection(struct file *file, void *priv,case V4L2_SEL_TGT_COMPOSE : s->r.left =0 ; s->r.top =0 ; - s->r.width = ctx->out_q.w; - s->r.height = ctx->out_q.h; + ctx->out_q.w = s->r.width; + ctx->out_q.h = s->r.height;break ;default :return -EINVAL ;
@@ -571,6 +541,13 @@ static int mtk_jpeg_queue_setup(struct vb2_queue *q,if (!q_data)return -EINVAL ; +if (*num_planes) { +for (i =0 ; i < *num_planes; i++) +if (sizes[i] < q_data->sizeimage[i]) +return -EINVAL ; +return 0 ; + } + *num_planes = q_data->fmt->colplanes;for (i =0 ; i < q_data->fmt->colplanes; i++) { sizes[i] = q_data->sizeimage[i];
@@ -764,8 +741,8 @@ static void mtk_jpeg_set_dec_src(struct mtk_jpeg_ctx *ctx, { bs->str_addr =vb2_dma_contig_plane_dma_addr (src_buf,0 ); bs->end_addr = bs->str_addr + -mtk_jpeg_align (vb2_get_plane_payload (src_buf,0 ),16 ); - bs->size =mtk_jpeg_align (vb2_plane_size (src_buf,0 ),128 ); +round_up (vb2_get_plane_payload (src_buf,0 ),16 ); + bs->size =round_up (vb2_plane_size (src_buf,0 ),128 ); } static int mtk_jpeg_set_dec_dst(struct mtk_jpeg_ctx *ctx,
@@ -801,7 +778,6 @@ static void mtk_jpeg_device_run(void *priv)struct mtk_jpeg_dev *jpeg = ctx->jpeg;struct vb2_v4l2_buffer *src_buf, *dst_buf;enum vb2_buffer_state buf_state =VB2_BUF_STATE_ERROR ; -unsigned long flags;struct mtk_jpeg_src_buf *jpeg_src_buf;struct mtk_jpeg_bs bs;struct mtk_jpeg_fb fb;
@@ -829,13 +805,11 @@ static void mtk_jpeg_device_run(void *priv)if (mtk_jpeg_set_dec_dst (ctx, &jpeg_src_buf->dec_param, &dst_buf->vb2_buf, &fb)) goto dec_end; -spin_lock_irqsave (&jpeg->hw_lock, flags);mtk_jpeg_dec_reset (jpeg->dec_reg_base);mtk_jpeg_dec_set_config (jpeg->dec_reg_base, &jpeg_src_buf->dec_param, &bs, &fb);mtk_jpeg_dec_start (jpeg->dec_reg_base); -spin_unlock_irqrestore (&jpeg->hw_lock, flags);return ; dec_end:
drivers/media/platform/mtk-jpeg/mtk_jpeg_core.h +5 -2
@@ -15,6 +15,8 @@#define MTK_JPEG_NAME "mtk-jpeg" +#define MTK_JPEG_COMP_MAX 3 +#define MTK_JPEG_FMT_FLAG_DEC_OUTPUT BIT(0)#define MTK_JPEG_FMT_FLAG_DEC_CAPTURE BIT(1)
@@ -28,6 +30,9 @@#define MTK_JPEG_DEFAULT_SIZEIMAGE (1 * 1024 * 1024) +/** +* enum mtk_jpeg_ctx_state - contex state of jpeg +*/ enum mtk_jpeg_ctx_state {MTK_JPEG_INIT =0 ,MTK_JPEG_RUNNING ,
@@ -107,9 +112,7 @@ struct mtk_jpeg_q_data {* @out_q: source (output) queue information * @cap_q: destination (capture) queue queue information * @fh: V4L2 file handle -* @dec_param parameters for HW decoding * @state: state of the context -* @header_valid: set if header has been parsed and valid * @colorspace: enum v4l2_colorspace; supplemental to pixelformat * @ycbcr_enc: enum v4l2_ycbcr_encoding, Y'CbCr encoding * @quantization: enum v4l2_quantization, colorspace quantization
drivers/media/platform/mtk-jpeg/mtk_jpeg_hw.c +4 -4
@@ -153,10 +153,10 @@ static int mtk_jpeg_calc_dst_size(struct mtk_jpeg_dec_param *param) param->sampling_w[i];/* output format is 420/422 */ param->comp_w[i] = padding_w >> brz_w[i]; - param->comp_w[i] =mtk_jpeg_align (param->comp_w[i], -MTK_JPEG_DCTSIZE ); - param->img_stride[i] = i ?mtk_jpeg_align (param->comp_w[i],16 ) - :mtk_jpeg_align (param->comp_w[i],32 ); + param->comp_w[i] =round_up (param->comp_w[i], +MTK_JPEG_DCTSIZE ); + param->img_stride[i] = i ?round_up (param->comp_w[i],16 ) + :round_up (param->comp_w[i],32 ); ds_row_h[i] = (MTK_JPEG_DCTSIZE * param->sampling_h[i]); } param->dec_w = param->img_stride[0 ];
drivers/media/platform/mtk-jpeg/mtk_jpeg_hw.h +0 -5
@@ -54,11 +54,6 @@ struct mtk_jpeg_dec_param {u8 uv_brz_w; }; -static inline u32 mtk_jpeg_align (u32 val,u32 align) -{ -return (val + align -1 ) & ~(align -1 ); -} -struct mtk_jpeg_bs {dma_addr_t str_addr;dma_addr_t end_addr;
drivers/media/platform/mtk-jpeg/mtk_jpeg_reg.h +9 -10
@@ -8,7 +8,6 @@#ifndef _MTK_JPEG_REG_H#define _MTK_JPEG_REG_H -#define MTK_JPEG_COMP_MAX 3#define MTK_JPEG_BLOCK_MAX 10#define MTK_JPEG_DCTSIZE 8
@@ -20,29 +19,29 @@#define BIT_INQST_MASK_ALLIRQ 0x37#define JPGDEC_REG_RESET 0x0090 -#define JPGDEC_REG_BRZ_FACTOR 0x00F8 -#define JPGDEC_REG_DU_NUM 0x00FC +#define JPGDEC_REG_BRZ_FACTOR 0x00f8 +#define JPGDEC_REG_DU_NUM 0x00fc#define JPGDEC_REG_DEST_ADDR0_Y 0x0140#define JPGDEC_REG_DEST_ADDR0_U 0x0144#define JPGDEC_REG_DEST_ADDR0_V 0x0148 -#define JPGDEC_REG_DEST_ADDR1_Y 0x014C +#define JPGDEC_REG_DEST_ADDR1_Y 0x014c#define JPGDEC_REG_DEST_ADDR1_U 0x0150#define JPGDEC_REG_DEST_ADDR1_V 0x0154#define JPGDEC_REG_STRIDE_Y 0x0158 -#define JPGDEC_REG_STRIDE_UV 0x015C +#define JPGDEC_REG_STRIDE_UV 0x015c#define JPGDEC_REG_IMG_STRIDE_Y 0x0160#define JPGDEC_REG_IMG_STRIDE_UV 0x0164 -#define JPGDEC_REG_WDMA_CTRL 0x016C +#define JPGDEC_REG_WDMA_CTRL 0x016c#define JPGDEC_REG_PAUSE_MCU_NUM 0x0170 -#define JPGDEC_REG_OPERATION_MODE 0x017C +#define JPGDEC_REG_OPERATION_MODE 0x017c#define JPGDEC_REG_FILE_ADDR 0x0200 -#define JPGDEC_REG_COMP_ID 0x020C +#define JPGDEC_REG_COMP_ID 0x020c#define JPGDEC_REG_TOTAL_MCU_NUM 0x0210#define JPGDEC_REG_COMP0_DATA_UNIT_NUM 0x0224 -#define JPGDEC_REG_DU_CTRL 0x023C +#define JPGDEC_REG_DU_CTRL 0x023c#define JPGDEC_REG_TRIG 0x0240#define JPGDEC_REG_FILE_BRP 0x0248 -#define JPGDEC_REG_FILE_TOTAL_SIZE 0x024C +#define JPGDEC_REG_FILE_TOTAL_SIZE 0x024c#define JPGDEC_REG_QT_ID 0x0270#define JPGDEC_REG_INTERRUPT_STATUS 0x0274#define JPGDEC_REG_STATUS 0x0278
Signature · 1 line
2.18.0
Re: [PATCH v6 1/5] media: platform: Fix jpeg dec driver bug and improve code quality
Hi Xia,
Quoted 7 lines · Xia Jiang
Fix v4l2-compliance test bug and improve code quality of jpeg decode driver, because the jpeg encode driver will base on it.
Signed-off-by Xia Jiang <[email protected]>---
v6: alignment 'MTK_JPEG_DCTSIZE' match open parenthesis.
Quoted 7 lines
v5: Use clamp()to replace
mtk_jpeg_bound_align_image()andround_up()
to replacemtk_jpeg_align().
Get correct compose value inmtk_jpeg_selection(). Cancel spin lock and unlock operation in device run function. Change register offset hex numberals from upercase to lowercase.v4: new add patch for v4l2-compliance test bug fix.
Thanks for the patch. The changes look good to me, but each of the unrelated changes should be split into its own patch, with proper explanation in its commit message. Especially the ones that introduce behavior changes, such as the S_SELECTION or locking change.
Also please see one comment inline.
[snip]
drivers/media/platform/mtk-jpeg/mtk_jpeg_core.c static void mtk_jpeg_device_run(void *priv) · line 832
Quoted 13 lines
drivers/media/platform/mtk-jpeg/mtk_jpeg_core.c +0
-2@@ -801,7 +778,6 @@ static void mtk_jpeg_device_run(void *priv)struct mtk_jpeg_dev *jpeg = ctx->jpeg;struct vb2_v4l2_buffer *src_buf, *dst_buf;enum vb2_buffer_state buf_state =VB2_BUF_STATE_ERROR ; -unsigned long flags;struct mtk_jpeg_src_buf *jpeg_src_buf;struct mtk_jpeg_bs bs;struct mtk_jpeg_fb fb;@@ -829,13 +805,11 @@ static void mtk_jpeg_device_run(void *priv)if (mtk_jpeg_set_dec_dst (ctx, &jpeg_src_buf->dec_param, &dst_buf->vb2_buf, &fb)) goto dec_end; -spin_lock_irqsave (&jpeg->hw_lock, flags);
Why is it safe to remove the locking here?
drivers/media/platform/mtk-jpeg/mtk_jpeg_core.c static void mtk_jpeg_device_run(void *priv) · line 815
Quoted 9 lines
drivers/media/platform/mtk-jpeg/mtk_jpeg_core.c +0
-1mtk_jpeg_dec_reset (jpeg->dec_reg_base);mtk_jpeg_dec_set_config (jpeg->dec_reg_base, &jpeg_src_buf->dec_param, &bs, &fb);mtk_jpeg_dec_start (jpeg->dec_reg_base); -spin_unlock_irqrestore (&jpeg->hw_lock, flags);return ; dec_end:
Best regards,
Tomasz
Re: [PATCH v6 1/5] media: platform: Fix jpeg dec driver bug and improve code quality
Quoted 39 lines · Tomasz Figa
Hi Xia,
Quoted 7 lines · Xia Jiang
Fix v4l2-compliance test bug and improve code quality of jpeg decode driver, because the jpeg encode driver will base on it.
Signed-off-by Xia Jiang <[email protected]>---
v6: alignment 'MTK_JPEG_DCTSIZE' match open parenthesis.Quoted 7 lines
v5: Use clamp()to replace
mtk_jpeg_bound_align_image()andround_up()
to replacemtk_jpeg_align().
Get correct compose value inmtk_jpeg_selection(). Cancel spin lock and unlock operation in device run function. Change register offset hex numberals from upercase to lowercase.v4: new add patch for v4l2-compliance test bug fix.
Thanks for the patch. The changes look good to me, but each of the unrelated changes should be split into its own patch, with proper explanation in its commit message. Especially the ones that introduce behavior changes, such as the
S_SELECTIONor locking change.Also please see one comment inline.
[snip]
Quoted 12 lines
drivers/media/platform/mtk-jpeg/mtk_jpeg_core.c +0
-1@@ -801,7 +778,6 @@ static void mtk_jpeg_device_run(void *priv)struct mtk_jpeg_dev *jpeg = ctx->jpeg;struct vb2_v4l2_buffer *src_buf, *dst_buf;enum vb2_buffer_state buf_state =VB2_BUF_STATE_ERROR ; -unsigned long flags;struct mtk_jpeg_src_buf *jpeg_src_buf;struct mtk_jpeg_bs bs;struct mtk_jpeg_fb fb;@@ -829,13 +805,11 @@ static void mtk_jpeg_device_run(void *priv)if (mtk_jpeg_set_dec_dst (ctx, &jpeg_src_buf->dec_param, &dst_buf->vb2_buf, &fb)) goto dec_end;
Quoted 3 lines
drivers/media/platform/mtk-jpeg/mtk_jpeg_core.c static void mtk_jpeg_device_run(void *priv) · line 832
Quoted 1 line
drivers/media/platform/mtk-jpeg/mtk_jpeg_core.c +0
-1-spin_lock_irqsave (&jpeg->hw_lock, flags);Why is it safe to remove the locking here?
Dear Tomasz,
I will split unrelated changes into different patches.
My opinion about remove locking is following(after deep thinking):
The device_run function can be only called once for one instance.
For multi-instance,is there any posssibility of hw override if removing locking?I think so. What about your further opinion?
Best Regards,
Xia Jiang
Quoted 13 lines
drivers/media/platform/mtk-jpeg/mtk_jpeg_core.c static void mtk_jpeg_device_run(void *priv) · line 815
Quoted 9 lines
drivers/media/platform/mtk-jpeg/mtk_jpeg_core.c +0
-1mtk_jpeg_dec_reset (jpeg->dec_reg_base);mtk_jpeg_dec_set_config (jpeg->dec_reg_base, &jpeg_src_buf->dec_param, &bs, &fb);mtk_jpeg_dec_start (jpeg->dec_reg_base); -spin_unlock_irqrestore (&jpeg->hw_lock, flags);return ; dec_end:Best regards,
Tomasz
PATCH v6 2/5 media: dt-bindings: Add jpeg enc device tree node document
In reply to Xia JiangAdd jpeg enc device tree node document
---
v6: no changes
v5: no changes
v4: no changes
v3: change compatible to SoC specific compatible
v2: no changes
--- .../bindings/media/mediatek-jpeg-encoder.txt | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 Documentation/devicetree/bindings/media/mediatek-jpeg-encoder.txt
Documentation/devicetree/bindings/media/mediatek-jpeg-encoder.txt new file +37 -0
@@ -0,0 +1,37 @@ +* MediaTek JPEG Encoder + +MediaTek JPEG Encoder is the JPEG encode hardware present in MediaTek SoCs + +Required properties: +- compatible : should be one of: + "mediatek,mt2701-jpgenc" + ... + followed by "mediatek,mtk-jpgenc" +- reg : physical base address of the JPEG encoder registers and length of + memory mapped region. +- interrupts : interrupt number to the interrupt controller. +- clocks: device clocks, see + Documentation/devicetree/bindings/clock/clock-bindings.txt for details. +- clock-names: must contain "jpgenc". It is the clock of JPEG encoder. +- power-domains: a phandle to the power domain, see + Documentation/devicetree/bindings/power/power_domain.txt for details. +- mediatek,larb: must contain the local arbiters in the current SoCs, see + Documentation/devicetree/bindings/memory-controllers/mediatek,smi-larb.txt + for details. +- iommus: should point to the respective IOMMU block with master port as + argument, see Documentation/devicetree/bindings/iommu/mediatek,iommu.txt + for details. + +Example: + jpegenc: jpegenc@1500a000 { + compatible = "mediatek,mt2701-jpgenc", + "mediatek,mtk-jpgenc"; + reg = <0 0x1500a000 0 0x1000>; + interrupts = <GIC_SPI 141 IRQ_TYPE_LEVEL_LOW>; + clocks = <&imgsys CLK_IMG_VENC>; + clock-names = "jpgenc"; + power-domains = <&scpsys MT2701_POWER_DOMAIN_ISP>; + mediatek,larb = <&larb2>; + iommus = <&iommu MT2701_M4U_PORT_JPGENC_RDMA>, + <&iommu MT2701_M4U_PORT_JPGENC_BSDMA>; + };
Signature · 1 line
2.18.0
PATCH v6 3/5 arm: dts: Add jpeg enc device tree node
In reply to Xia JiangAdd jpeg enc device tree node
---
v6: no changes
v5: no changes
v4: no changes
v3: change compatible to SoC specific compatible
v2: no changes
--- arch/arm/boot/dts/mt2701.dtsi | 13 +++++++++++++ 1 file changed, 13 insertions(+)
arch/arm/boot/dts/mt2701.dtsi +13 -0
@@ -569,6 +569,19 @@ <&iommu MT2701_M4U_PORT_JPGDEC_BSDMA>; }; + jpegenc: jpegenc@1500a000 { + compatible = "mediatek,mt2701-jpgenc", + "mediatek,mtk-jpgenc"; + reg = <0 0x1500a000 0 0x1000>; + interrupts = <GIC_SPI 141 IRQ_TYPE_LEVEL_LOW>; + clocks = <&imgsys CLK_IMG_VENC>; + clock-names = "jpgenc"; + power-domains = <&scpsys MT2701_POWER_DOMAIN_ISP>; + mediatek,larb = <&larb2>; + iommus = <&iommu MT2701_M4U_PORT_JPGENC_RDMA>, + <&iommu MT2701_M4U_PORT_JPGENC_BSDMA>; + }; + vdecsys: syscon@16000000 { compatible = "mediatek,mt2701-vdecsys", "syscon"; reg = <0 0x16000000 0 0x1000>;
Signature · 1 line
2.18.0
PATCH v6 4/5 media: platform: Rename jpeg dec file name
In reply to Xia JiangRename the files which are for decode feature. This is preparing path since the jpeg enc patch will be added later.
---
v6: no changes
v5: no changes
v4: no changes
v3: no changes
v2: no changes
---
drivers/media/platform/mtk-jpeg/Makefile | 2 +-
drivers/media/platform/mtk-jpeg/mtk_jpeg_core.c | 4 ++--
.../platform/mtk-jpeg/{mtk_jpeg_hw.c => mtk_jpeg_dec_hw.c} | 2 +-
.../platform/mtk-jpeg/{mtk_jpeg_hw.h => mtk_jpeg_dec_hw.h} | 2 +-
.../mtk-jpeg/{mtk_jpeg_parse.c => mtk_jpeg_dec_parse.c} | 2 +-
.../mtk-jpeg/{mtk_jpeg_parse.h => mtk_jpeg_dec_parse.h} | 2 +-
.../platform/mtk-jpeg/{mtk_jpeg_reg.h => mtk_jpeg_dec_reg.h} | 0
7 files changed, 7 insertions(+), 7 deletions(-)
rename drivers/media/platform/mtk-jpeg/{mtk_jpeg_hw.c => mtk_jpeg_dec_hw.c} (99%)
rename drivers/media/platform/mtk-jpeg/{mtk_jpeg_hw.h => mtk_jpeg_dec_hw.h} (98%)
rename drivers/media/platform/mtk-jpeg/{mtk_jpeg_parse.c => mtk_jpeg_dec_parse.c} (98%)
rename drivers/media/platform/mtk-jpeg/{mtk_jpeg_parse.h => mtk_jpeg_dec_parse.h} (92%)
rename drivers/media/platform/mtk-jpeg/{mtk_jpeg_reg.h => mtk_jpeg_dec_reg.h} (100%)drivers/media/platform/mtk-jpeg/Makefile +1 -1
@@ -1,3 +1,3 @@ # SPDX-License-Identifier: GPL-2.0-only -mtk_jpeg-objs := mtk_jpeg_core.o mtk_jpeg_hw.o mtk_jpeg_parse.o +mtk_jpeg-objs := mtk_jpeg_core.o mtk_jpeg_dec_hw.o mtk_jpeg_dec_parse.o obj-$(CONFIG_VIDEO_MEDIATEK_JPEG) += mtk_jpeg.o
drivers/media/platform/mtk-jpeg/mtk_jpeg_core.c +2 -2
@@ -23,9 +23,9 @@#include <media/videobuf2-dma-contig.h> #include <soc/mediatek/smi.h> -#include "mtk_jpeg_hw.h" +#include "mtk_jpeg_dec_hw.h" #include "mtk_jpeg_core.h" -#include "mtk_jpeg_parse.h" +#include "mtk_jpeg_dec_parse.h" static struct mtk_jpeg_fmt mtk_jpeg_formats[] = { {
drivers/media/platform/mtk-jpeg/mtk_jpeg_dec_hw.c renamed from drivers/media/platform/mtk-jpeg/mtk_jpeg_hw.c +1 -1
@@ -9,7 +9,7 @@#include <linux/kernel.h> #include <media/videobuf2-core.h> -#include "mtk_jpeg_hw.h" +#include "mtk_jpeg_dec_hw.h" #define MTK_JPEG_DUNUM_MASK (val) (((val) - 1) & 0x3)
drivers/media/platform/mtk-jpeg/mtk_jpeg_dec_hw.h renamed from drivers/media/platform/mtk-jpeg/mtk_jpeg_hw.h +1 -1
@@ -11,7 +11,7 @@#include <media/videobuf2-core.h> #include "mtk_jpeg_core.h" -#include "mtk_jpeg_reg.h" +#include "mtk_jpeg_dec_reg.h" enum {MTK_JPEG_DEC_RESULT_EOF_DONE =0 ,
drivers/media/platform/mtk-jpeg/mtk_jpeg_dec_parse.c renamed from drivers/media/platform/mtk-jpeg/mtk_jpeg_parse.c +1 -1
@@ -8,7 +8,7 @@#include <linux/kernel.h> #include <linux/videodev2.h> -#include "mtk_jpeg_parse.h" +#include "mtk_jpeg_dec_parse.h" #define TEM 0x01#define SOF0 0xc0
drivers/media/platform/mtk-jpeg/mtk_jpeg_dec_parse.h renamed from drivers/media/platform/mtk-jpeg/mtk_jpeg_parse.h +1 -1
@@ -8,7 +8,7 @@#ifndef _MTK_JPEG_PARSE_H#define _MTK_JPEG_PARSE_H -#include "mtk_jpeg_hw.h" +#include "mtk_jpeg_dec_hw.h" bool mtk_jpeg_parse (struct mtk_jpeg_dec_param *param,u8 *src_addr_va,u32 src_size);
drivers/media/platform/mtk-jpeg/mtk_jpeg_dec_reg.h renamed from drivers/media/platform/mtk-jpeg/mtk_jpeg_reg.h +0 -0
Signature · 1 line
2.18.0
PATCH v6 5/5 media: platform: Add jpeg dec/enc feature
In reply to Xia JiangAdd mtk jpeg encode v4l2 driver based on jpeg decode, because that jpeg decode and encode have great similarities with function operation.
---
v6: add space to arounding '+'.
alignment 'struct mtk_jpeg_fmt *fmt' match open parenthesis. change 'mtk_jpeg_enc_set_encFormat' to 'mtk_jpeg_enc_set_enc_format'. make 'mtk_jpeg_ctrls_setup' to static prototype.
delete unused variables 'jpeg'/'align_h'/'align_w'/'flags'. initialize 'yuv_format'/'enc_quality' variables.
v5: support crop for encoder and compose for decoder in s_selection and
g_selection function.
use clamp() to replace mtk_jpeg_bound_align_image() and round_up() to replace mtk_jpeg_align().
delete jpeg_enc_param/mtk_jpeg_enc_param structure and mtk_jpeg_set_param(), program the registers directly based on the original V4L2 values.
move macro definition about hw to mtk_jpeg_enc_reg.h. delete unnecessary V4L2 logs in driver.
cancel spin lock and unlock operation in deviec run function. change jpeg enc register offset hex numberals from upercase to lowercase.
v4: split mtk_jpeg_try_fmt_mplane() to two functions, one for encoder,
one for decoder.
split mtk_jpeg_set_default_params() to two functions, one for encoder, one for decoder.
add cropping support for encoder in g/s_selection ioctls. change exif mode support by using V4L2_JPEG_ACTIVE_MARKER_APP1. change MTK_JPEG_MAX_WIDTH/MTK_JPEG_MAX_HEIGH from 8192 to 65535 by specification.
move width shifting operation behind aligning operation in mtk_jpeg_try_enc_fmt_mplane() for bug fix.
fix user abuseing data_offset issue for DMABUF in mtk_jpeg_set_enc_src().
fix kbuild warings: change MTK_JPEG_MIN_HEIGHT/MTK_JPEG_MAX_HEIGHT
and MTK_JPEG_MIN_WIDTH/MTK_JPEG_MAX_WIDTH from 'int' type to 'unsigned int' type. fix msleadingly indented of 'else'.
v3: delete Change-Id.
only test once handler->error after the last v4l2_ctrl_new_std(). seperate changes of v4l2-ctrls.c and v4l2-controls.h to new patch.
v2: fix compliance test fail, check created buffer size in driver.
--- drivers/media/platform/mtk-jpeg/Makefile | 5 +- .../media/platform/mtk-jpeg/mtk_jpeg_core.c | 681 ++++++++++++++---- .../media/platform/mtk-jpeg/mtk_jpeg_core.h | 43 +- .../media/platform/mtk-jpeg/mtk_jpeg_dec_hw.h | 7 +- .../media/platform/mtk-jpeg/mtk_jpeg_enc_hw.c | 273 +++++++ .../media/platform/mtk-jpeg/mtk_jpeg_enc_hw.h | 86 +++ .../platform/mtk-jpeg/mtk_jpeg_enc_reg.h | 78 ++ 7 files changed, 1007 insertions(+), 166 deletions(-) create mode 100644 drivers/media/platform/mtk-jpeg/mtk_jpeg_enc_hw.c create mode 100644 drivers/media/platform/mtk-jpeg/mtk_jpeg_enc_hw.h create mode 100644 drivers/media/platform/mtk-jpeg/mtk_jpeg_enc_reg.h
drivers/media/platform/mtk-jpeg/Makefile +4 -1
@@ -1,3 +1,6 @@ # SPDX-License-Identifier: GPL-2.0-only -mtk_jpeg-objs := mtk_jpeg_core.o mtk_jpeg_dec_hw.o mtk_jpeg_dec_parse.o +mtk_jpeg-objs := mtk_jpeg_core.o \ + mtk_jpeg_dec_hw.o \ + mtk_jpeg_dec_parse.o \ + mtk_jpeg_enc_hw.o obj-$(CONFIG_VIDEO_MEDIATEK_JPEG) += mtk_jpeg.o
drivers/media/platform/mtk-jpeg/mtk_jpeg_core.c +531 -150
970 lines not on this page · raw message
drivers/media/platform/mtk-jpeg/mtk_jpeg_core.h +31 -12
93 lines not on this page · raw message
drivers/media/platform/mtk-jpeg/mtk_jpeg_dec_hw.h +4 -3
@@ -3,10 +3,11 @@* Copyright (c) 2016 MediaTek Inc. * Author: Ming Hsiu Tsai <[email protected]> * Rick Chang <[email protected]> +* Xia Jiang <[email protected]> */ -#ifndef _MTK_JPEG_HW_H -#define _MTK_JPEG_HW_H +#ifndef _MTK_JPEG_DEC_HW_H +#define _MTK_JPEG_DEC_HW_H#include <media/videobuf2-core.h>
@@ -75,4 +76,4 @@ void mtk_jpeg_dec_set_config(void __iomem *base,void mtk_jpeg_dec_reset (void __iomem *dec_reg_base);void mtk_jpeg_dec_start (void __iomem *dec_reg_base); -#endif /* _MTK_JPEG_HW_H */ +#endif /* _MTK_JPEG_DEC_HW_H */
drivers/media/platform/mtk-jpeg/mtk_jpeg_enc_hw.c new file +273 -0
273 lines not on this page · raw message
drivers/media/platform/mtk-jpeg/mtk_jpeg_enc_hw.h new file +86 -0
86 lines not on this page · raw message
drivers/media/platform/mtk-jpeg/mtk_jpeg_enc_reg.h new file +78 -0
78 lines not on this page · raw message
Signature · 1 line
2.18.0