Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp5184131ybi; Tue, 4 Jun 2019 02:39:51 -0700 (PDT) X-Google-Smtp-Source: APXvYqwk6gRfDAXfK04piYsVuaK86QYDPPRwPlVgvCF77CTiFJvCNBDlodV07blQKHZyiMigR54q X-Received: by 2002:a65:52c9:: with SMTP id z9mr26558470pgp.177.1559641191109; Tue, 04 Jun 2019 02:39:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559641191; cv=none; d=google.com; s=arc-20160816; b=jwA2jYWAlUAyj87C6Myo67vONIZsDRJhENbbGsMrncnVsWMYhra+qjdBfCNsSAf87R YquL1hxdZtAT+Dj8ZraNvcR0V/domY/oyuqsmlJlDlzARoNNANF3/+CTfPoY/N5XcJGr LvLIesKTnnCGuTT1pXCwKVpiqJvBEkyA/EieGpEVTAjF258H3Tb28moI//3cfl7WG4Se uF0RlK9OYS3OYluVZQYdmhOF1hxsdFGhHMdqk6f3L8rCEOhzYpKREIDSDfjyuxA1DMJZ qtaiH5GeOP8OX+7A+0C0F4t6suOVaw7C6x63paCW4KhWCOnc6x88Ibjf3khvrWsgH/81 X7nw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=Kkz/XzAOhnm/D/+CBYg1z225Vw/50tqayYaD8NUxlbU=; b=AQeA3MXBEZ1oWWO4W9XmoRsjD5QWeEHby8RwV3ZJ+u8xc24CdHuJCY4NLo7aNaunG5 /YnW7lDkzfzvVlSqfaBOQeH3bS8AuGB+rZmKyKO0ZnNjHsUoqO4cJl+DfFcawX/pAizS RiDU6XkwoZjK/tUORbTf33zDSCtVsgywjBrzxCEFDCv/85jFXQh4DTPRp90ukWApnmZe QylpPVmzLdHUztay4+LG70tSpJ5vjxozppRF5wOvoPZqTqRlbSYhdvRePoPhBYrN2ahD IyOFIR7HpWp9tOf/csL3d4UdOfhWAoLBSg4p8SfGxNeaAsi7sSe2sWHNVScSvm5A4MED 1zqQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=lNej2GHp; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n16si5048908pgc.85.2019.06.04.02.39.34; Tue, 04 Jun 2019 02:39:51 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=lNej2GHp; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727179AbfFDJiJ (ORCPT + 99 others); Tue, 4 Jun 2019 05:38:09 -0400 Received: from mail-pf1-f195.google.com ([209.85.210.195]:38475 "EHLO mail-pf1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727167AbfFDJiF (ORCPT ); Tue, 4 Jun 2019 05:38:05 -0400 Received: by mail-pf1-f195.google.com with SMTP id a186so11638012pfa.5 for ; Tue, 04 Jun 2019 02:38:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Kkz/XzAOhnm/D/+CBYg1z225Vw/50tqayYaD8NUxlbU=; b=lNej2GHpJFHhSX5Wafo2JC+jKDIiMJEwglY1egsj2tTgl0CQtE88cOwbO0CgShR/KB Ei4wKW9rV86pYeUnXfZu+AQwz61DDo54QbRPMjYNhpkuvX3qkzL+8VGxuV7UGUS6G+jC NfY7SaKvaII5e5ct8H33XKnTvOJMIVnIWbuCQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Kkz/XzAOhnm/D/+CBYg1z225Vw/50tqayYaD8NUxlbU=; b=mhMxB2mF07ThkKpol5A5hUmM5dAhWX3bCIjsqOnKrh8EpWtwxKbZlrBEInligSqDs9 zOrKPnYg4oZ949ydZCZaaO6bgy0T8ou09P5H+Me+7GJatHDngl6+IuXS1WFUyIAYUmD4 5XmrbZjcZVg19g7oOvUO4xpgtn+oMV8mkVvSzw5dHcgFH62m8X7Zuv6TAtDk+QlzPYYe qQeX71q0UGTv2i4vc8altGlqmvmC9wexVBEiC/p40MdF2LOY79znxPuEqH/thvHJszmj VRNuf3mh7FhioJ6SmJR96p1WpDjztYnSc0biPZbAxO4zOR4yeUmE3nNL6DzOfuVT3PQv pQrA== X-Gm-Message-State: APjAAAVRbNS3VNgkMZvKQqdW5v2X+2G8CTxcM0Lwf57tH88CYwGkpZDm ce5Jv0CDTd0KMTYY0dMboZBlRQ== X-Received: by 2002:a17:90a:372a:: with SMTP id u39mr7218059pjb.2.1559641084175; Tue, 04 Jun 2019 02:38:04 -0700 (PDT) Received: from acourbot.tok.corp.google.com ([2401:fa00:4:4:9712:8cf1:d0f:7d33]) by smtp.gmail.com with ESMTPSA id j7sm17431588pfa.184.2019.06.04.02.38.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 04 Jun 2019 02:38:03 -0700 (PDT) From: Alexandre Courbot To: Tiffany Lin , Andrew-CT Chen , Mauro Carvalho Chehab , Yunfei Dong , Hans Verkuil Cc: linux-media@vger.kernel.org, linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org, Alexandre Courbot Subject: [PATCH 4/5] media: mtk-vcodec: constify formats Date: Tue, 4 Jun 2019 18:37:36 +0900 Message-Id: <20190604093737.172599-5-acourbot@chromium.org> X-Mailer: git-send-email 2.22.0.rc1.311.g5d7573a151-goog In-Reply-To: <20190604093737.172599-1-acourbot@chromium.org> References: <20190604093737.172599-1-acourbot@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Formats are read-only internal memory structures, so make them const. Signed-off-by: Alexandre Courbot --- .../platform/mtk-vcodec/mtk_vcodec_dec.c | 19 ++++++++++--------- .../platform/mtk-vcodec/mtk_vcodec_drv.h | 2 +- .../platform/mtk-vcodec/mtk_vcodec_enc.c | 19 ++++++++++--------- 3 files changed, 21 insertions(+), 19 deletions(-) diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c index 371e70d6a803..131a8117ece2 100644 --- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c +++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c @@ -19,7 +19,7 @@ #define DFT_CFG_WIDTH MTK_VDEC_MIN_W #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, .type = MTK_FMT_DEC, @@ -63,9 +63,9 @@ static const struct mtk_codec_framesizes mtk_vdec_framesizes[] = { #define NUM_SUPPORTED_FRAMESIZE ARRAY_SIZE(mtk_vdec_framesizes) #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; for (k = 0; k < NUM_FORMATS; k++) { @@ -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, unsigned int pixelformat) { - struct mtk_video_fmt *fmt; + const struct mtk_video_fmt *fmt; struct mtk_q_data *dst_q_data; unsigned int k; @@ -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; int i; @@ -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, struct v4l2_format *f) { - struct mtk_video_fmt *fmt; + const struct mtk_video_fmt *fmt; fmt = mtk_vdec_find_format(f); if (!fmt) { @@ -727,7 +728,7 @@ static int vidioc_try_fmt_vid_out_mplane(struct file *file, void *priv, struct v4l2_format *f) { 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); if (!fmt) { @@ -821,7 +822,7 @@ static int vidioc_vdec_s_fmt(struct file *file, void *priv, struct v4l2_pix_format_mplane *pix_mp; struct mtk_q_data *q_data; int ret = 0; - struct mtk_video_fmt *fmt; + const struct mtk_video_fmt *fmt; mtk_v4l2_debug(3, "[%d]", ctx->id); @@ -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) { - struct mtk_video_fmt *fmt; + const struct mtk_video_fmt *fmt; int i, j = 0; for (i = 0; i < NUM_FORMATS; i++) { diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h b/drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h index 4b10996e6532..0a29a0694124 100644 --- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h +++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_drv.h @@ -124,7 +124,7 @@ struct mtk_q_data { enum v4l2_field field; unsigned int bytesperline[MTK_VCODEC_MAX_PLANES]; unsigned int sizeimage[MTK_VCODEC_MAX_PLANES]; - struct mtk_video_fmt *fmt; + const struct mtk_video_fmt *fmt; }; /** diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c b/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c index 1a3845809b92..868147616da7 100644 --- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c +++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c @@ -24,7 +24,7 @@ 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, .type = MTK_FMT_FRAME, @@ -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) { - struct mtk_video_fmt *fmt; + const struct mtk_video_fmt *fmt; int i, j = 0; 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, 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; for (k = 0; k < NUM_FORMATS; k++) { @@ -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 * 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; int i; @@ -414,7 +415,7 @@ static int vidioc_venc_s_fmt_cap(struct file *file, void *priv, struct vb2_queue *vq; struct mtk_q_data *q_data; int i, ret; - struct mtk_video_fmt *fmt; + const struct mtk_video_fmt *fmt; vq = v4l2_m2m_get_vq(ctx->m2m_ctx, f->type); if (!vq) { @@ -476,7 +477,7 @@ static int vidioc_venc_s_fmt_out(struct file *file, void *priv, struct vb2_queue *vq; struct mtk_q_data *q_data; 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; 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, static int vidioc_try_fmt_vid_cap_mplane(struct file *file, void *priv, struct v4l2_format *f) { - struct mtk_video_fmt *fmt; + const struct mtk_video_fmt *fmt; struct mtk_vcodec_ctx *ctx = fh_to_ctx(priv); fmt = mtk_venc_find_format(f); @@ -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, struct v4l2_format *f) { - struct mtk_video_fmt *fmt; + const struct mtk_video_fmt *fmt; fmt = mtk_venc_find_format(f); if (!fmt) { -- 2.22.0.rc1.311.g5d7573a151-goog