Commit 0a7ff71e authored by Alexandre Courbot's avatar Alexandre Courbot Committed by Mauro Carvalho Chehab

media: mtk-vcodec: constify formats

Formats are read-only internal memory structures, so make them const.
Signed-off-by: default avatarAlexandre Courbot <acourbot@chromium.org>
Signed-off-by: default avatarHans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+samsung@kernel.org>
parent 9293e39c
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
#define DFT_CFG_WIDTH MTK_VDEC_MIN_W #define DFT_CFG_WIDTH MTK_VDEC_MIN_W
#define DFT_CFG_HEIGHT MTK_VDEC_MIN_H #define DFT_CFG_HEIGHT MTK_VDEC_MIN_H
static struct mtk_video_fmt mtk_video_formats[] = { static const struct mtk_video_fmt mtk_video_formats[] = {
{ {
.fourcc = V4L2_PIX_FMT_H264, .fourcc = V4L2_PIX_FMT_H264,
.type = MTK_FMT_DEC, .type = MTK_FMT_DEC,
...@@ -63,9 +63,9 @@ static const struct mtk_codec_framesizes mtk_vdec_framesizes[] = { ...@@ -63,9 +63,9 @@ static const struct mtk_codec_framesizes mtk_vdec_framesizes[] = {
#define NUM_SUPPORTED_FRAMESIZE ARRAY_SIZE(mtk_vdec_framesizes) #define NUM_SUPPORTED_FRAMESIZE ARRAY_SIZE(mtk_vdec_framesizes)
#define NUM_FORMATS ARRAY_SIZE(mtk_video_formats) #define NUM_FORMATS ARRAY_SIZE(mtk_video_formats)
static struct mtk_video_fmt *mtk_vdec_find_format(struct v4l2_format *f) static const struct mtk_video_fmt *mtk_vdec_find_format(struct v4l2_format *f)
{ {
struct mtk_video_fmt *fmt; const struct mtk_video_fmt *fmt;
unsigned int k; unsigned int k;
for (k = 0; k < NUM_FORMATS; k++) { for (k = 0; k < NUM_FORMATS; k++) {
...@@ -266,7 +266,7 @@ static void mtk_vdec_flush_decoder(struct mtk_vcodec_ctx *ctx) ...@@ -266,7 +266,7 @@ static void mtk_vdec_flush_decoder(struct mtk_vcodec_ctx *ctx)
static void mtk_vdec_update_fmt(struct mtk_vcodec_ctx *ctx, static void mtk_vdec_update_fmt(struct mtk_vcodec_ctx *ctx,
unsigned int pixelformat) unsigned int pixelformat)
{ {
struct mtk_video_fmt *fmt; const struct mtk_video_fmt *fmt;
struct mtk_q_data *dst_q_data; struct mtk_q_data *dst_q_data;
unsigned int k; unsigned int k;
...@@ -639,7 +639,8 @@ static int vidioc_vdec_subscribe_evt(struct v4l2_fh *fh, ...@@ -639,7 +639,8 @@ static int vidioc_vdec_subscribe_evt(struct v4l2_fh *fh,
} }
} }
static int vidioc_try_fmt(struct v4l2_format *f, struct mtk_video_fmt *fmt) static int vidioc_try_fmt(struct v4l2_format *f,
const struct mtk_video_fmt *fmt)
{ {
struct v4l2_pix_format_mplane *pix_fmt_mp = &f->fmt.pix_mp; struct v4l2_pix_format_mplane *pix_fmt_mp = &f->fmt.pix_mp;
int i; int i;
...@@ -712,7 +713,7 @@ static int vidioc_try_fmt(struct v4l2_format *f, struct mtk_video_fmt *fmt) ...@@ -712,7 +713,7 @@ static int vidioc_try_fmt(struct v4l2_format *f, struct mtk_video_fmt *fmt)
static int vidioc_try_fmt_vid_cap_mplane(struct file *file, void *priv, static int vidioc_try_fmt_vid_cap_mplane(struct file *file, void *priv,
struct v4l2_format *f) struct v4l2_format *f)
{ {
struct mtk_video_fmt *fmt; const struct mtk_video_fmt *fmt;
fmt = mtk_vdec_find_format(f); fmt = mtk_vdec_find_format(f);
if (!fmt) { if (!fmt) {
...@@ -727,7 +728,7 @@ static int vidioc_try_fmt_vid_out_mplane(struct file *file, void *priv, ...@@ -727,7 +728,7 @@ static int vidioc_try_fmt_vid_out_mplane(struct file *file, void *priv,
struct v4l2_format *f) struct v4l2_format *f)
{ {
struct v4l2_pix_format_mplane *pix_fmt_mp = &f->fmt.pix_mp; struct v4l2_pix_format_mplane *pix_fmt_mp = &f->fmt.pix_mp;
struct mtk_video_fmt *fmt; const struct mtk_video_fmt *fmt;
fmt = mtk_vdec_find_format(f); fmt = mtk_vdec_find_format(f);
if (!fmt) { if (!fmt) {
...@@ -821,7 +822,7 @@ static int vidioc_vdec_s_fmt(struct file *file, void *priv, ...@@ -821,7 +822,7 @@ static int vidioc_vdec_s_fmt(struct file *file, void *priv,
struct v4l2_pix_format_mplane *pix_mp; struct v4l2_pix_format_mplane *pix_mp;
struct mtk_q_data *q_data; struct mtk_q_data *q_data;
int ret = 0; int ret = 0;
struct mtk_video_fmt *fmt; const struct mtk_video_fmt *fmt;
mtk_v4l2_debug(3, "[%d]", ctx->id); mtk_v4l2_debug(3, "[%d]", ctx->id);
...@@ -920,7 +921,7 @@ static int vidioc_enum_framesizes(struct file *file, void *priv, ...@@ -920,7 +921,7 @@ static int vidioc_enum_framesizes(struct file *file, void *priv,
static int vidioc_enum_fmt(struct v4l2_fmtdesc *f, bool output_queue) static int vidioc_enum_fmt(struct v4l2_fmtdesc *f, bool output_queue)
{ {
struct mtk_video_fmt *fmt; const struct mtk_video_fmt *fmt;
int i, j = 0; int i, j = 0;
for (i = 0; i < NUM_FORMATS; i++) { for (i = 0; i < NUM_FORMATS; i++) {
......
...@@ -124,7 +124,7 @@ struct mtk_q_data { ...@@ -124,7 +124,7 @@ struct mtk_q_data {
enum v4l2_field field; enum v4l2_field field;
unsigned int bytesperline[MTK_VCODEC_MAX_PLANES]; unsigned int bytesperline[MTK_VCODEC_MAX_PLANES];
unsigned int sizeimage[MTK_VCODEC_MAX_PLANES]; unsigned int sizeimage[MTK_VCODEC_MAX_PLANES];
struct mtk_video_fmt *fmt; const struct mtk_video_fmt *fmt;
}; };
/** /**
......
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
static void mtk_venc_worker(struct work_struct *work); static void mtk_venc_worker(struct work_struct *work);
static struct mtk_video_fmt mtk_video_formats[] = { static const struct mtk_video_fmt mtk_video_formats[] = {
{ {
.fourcc = V4L2_PIX_FMT_NV12M, .fourcc = V4L2_PIX_FMT_NV12M,
.type = MTK_FMT_FRAME, .type = MTK_FMT_FRAME,
...@@ -153,7 +153,7 @@ static const struct v4l2_ctrl_ops mtk_vcodec_enc_ctrl_ops = { ...@@ -153,7 +153,7 @@ static const struct v4l2_ctrl_ops mtk_vcodec_enc_ctrl_ops = {
static int vidioc_enum_fmt(struct v4l2_fmtdesc *f, bool output_queue) static int vidioc_enum_fmt(struct v4l2_fmtdesc *f, bool output_queue)
{ {
struct mtk_video_fmt *fmt; const struct mtk_video_fmt *fmt;
int i, j = 0; int i, j = 0;
for (i = 0; i < NUM_FORMATS; ++i) { for (i = 0; i < NUM_FORMATS; ++i) {
...@@ -261,9 +261,9 @@ static struct mtk_q_data *mtk_venc_get_q_data(struct mtk_vcodec_ctx *ctx, ...@@ -261,9 +261,9 @@ static struct mtk_q_data *mtk_venc_get_q_data(struct mtk_vcodec_ctx *ctx,
return &ctx->q_data[MTK_Q_DATA_DST]; return &ctx->q_data[MTK_Q_DATA_DST];
} }
static struct mtk_video_fmt *mtk_venc_find_format(struct v4l2_format *f) static const struct mtk_video_fmt *mtk_venc_find_format(struct v4l2_format *f)
{ {
struct mtk_video_fmt *fmt; const struct mtk_video_fmt *fmt;
unsigned int k; unsigned int k;
for (k = 0; k < NUM_FORMATS; k++) { for (k = 0; k < NUM_FORMATS; k++) {
...@@ -278,7 +278,8 @@ static struct mtk_video_fmt *mtk_venc_find_format(struct v4l2_format *f) ...@@ -278,7 +278,8 @@ static struct mtk_video_fmt *mtk_venc_find_format(struct v4l2_format *f)
/* V4L2 specification suggests the driver corrects the format struct if any of /* V4L2 specification suggests the driver corrects the format struct if any of
* the dimensions is unsupported * the dimensions is unsupported
*/ */
static int vidioc_try_fmt(struct v4l2_format *f, struct mtk_video_fmt *fmt) static int vidioc_try_fmt(struct v4l2_format *f,
const struct mtk_video_fmt *fmt)
{ {
struct v4l2_pix_format_mplane *pix_fmt_mp = &f->fmt.pix_mp; struct v4l2_pix_format_mplane *pix_fmt_mp = &f->fmt.pix_mp;
int i; int i;
...@@ -414,7 +415,7 @@ static int vidioc_venc_s_fmt_cap(struct file *file, void *priv, ...@@ -414,7 +415,7 @@ static int vidioc_venc_s_fmt_cap(struct file *file, void *priv,
struct vb2_queue *vq; struct vb2_queue *vq;
struct mtk_q_data *q_data; struct mtk_q_data *q_data;
int i, ret; int i, ret;
struct mtk_video_fmt *fmt; const struct mtk_video_fmt *fmt;
vq = v4l2_m2m_get_vq(ctx->m2m_ctx, f->type); vq = v4l2_m2m_get_vq(ctx->m2m_ctx, f->type);
if (!vq) { if (!vq) {
...@@ -476,7 +477,7 @@ static int vidioc_venc_s_fmt_out(struct file *file, void *priv, ...@@ -476,7 +477,7 @@ static int vidioc_venc_s_fmt_out(struct file *file, void *priv,
struct vb2_queue *vq; struct vb2_queue *vq;
struct mtk_q_data *q_data; struct mtk_q_data *q_data;
int ret, i; int ret, i;
struct mtk_video_fmt *fmt; const struct mtk_video_fmt *fmt;
struct v4l2_pix_format_mplane *pix_fmt_mp = &f->fmt.pix_mp; struct v4l2_pix_format_mplane *pix_fmt_mp = &f->fmt.pix_mp;
vq = v4l2_m2m_get_vq(ctx->m2m_ctx, f->type); vq = v4l2_m2m_get_vq(ctx->m2m_ctx, f->type);
...@@ -575,7 +576,7 @@ static int vidioc_venc_g_fmt(struct file *file, void *priv, ...@@ -575,7 +576,7 @@ static int vidioc_venc_g_fmt(struct file *file, void *priv,
static int vidioc_try_fmt_vid_cap_mplane(struct file *file, void *priv, static int vidioc_try_fmt_vid_cap_mplane(struct file *file, void *priv,
struct v4l2_format *f) struct v4l2_format *f)
{ {
struct mtk_video_fmt *fmt; const struct mtk_video_fmt *fmt;
struct mtk_vcodec_ctx *ctx = fh_to_ctx(priv); struct mtk_vcodec_ctx *ctx = fh_to_ctx(priv);
fmt = mtk_venc_find_format(f); fmt = mtk_venc_find_format(f);
...@@ -594,7 +595,7 @@ static int vidioc_try_fmt_vid_cap_mplane(struct file *file, void *priv, ...@@ -594,7 +595,7 @@ static int vidioc_try_fmt_vid_cap_mplane(struct file *file, void *priv,
static int vidioc_try_fmt_vid_out_mplane(struct file *file, void *priv, static int vidioc_try_fmt_vid_out_mplane(struct file *file, void *priv,
struct v4l2_format *f) struct v4l2_format *f)
{ {
struct mtk_video_fmt *fmt; const struct mtk_video_fmt *fmt;
fmt = mtk_venc_find_format(f); fmt = mtk_venc_find_format(f);
if (!fmt) { if (!fmt) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment