From: Michael Chang Date: Tue, 8 Apr 2025 05:54:54 +0000 (+0800) Subject: media: nuvoton: npcm-video: Prevent returning unsupported resolutions X-Git-Tag: v6.16-rc1~145^2~143 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e2ff3200065283b795f9800b9e03a93dd0d9f7e3;p=thirdparty%2Fkernel%2Flinux.git media: nuvoton: npcm-video: Prevent returning unsupported resolutions To restrict the returned resolution due to Nuvoton SoC hardware limitations. Signed-off-by: Michael Chang Signed-off-by: Hans Verkuil --- diff --git a/drivers/media/platform/nuvoton/npcm-video.c b/drivers/media/platform/nuvoton/npcm-video.c index 3022fdcf66ec7..44e904e61801e 100644 --- a/drivers/media/platform/nuvoton/npcm-video.c +++ b/drivers/media/platform/nuvoton/npcm-video.c @@ -578,7 +578,7 @@ static unsigned int npcm_video_hres(struct npcm_video *video) regmap_read(gfxi, HVCNTL, &hvcntl); apb_hor_res = (((hvcnth & HVCNTH_MASK) << 8) + (hvcntl & HVCNTL_MASK) + 1); - return apb_hor_res; + return (apb_hor_res > MAX_WIDTH) ? MAX_WIDTH : apb_hor_res; } static unsigned int npcm_video_vres(struct npcm_video *video) @@ -591,7 +591,7 @@ static unsigned int npcm_video_vres(struct npcm_video *video) apb_ver_res = (((vvcnth & VVCNTH_MASK) << 8) + (vvcntl & VVCNTL_MASK)); - return apb_ver_res; + return (apb_ver_res > MAX_HEIGHT) ? MAX_HEIGHT : apb_ver_res; } static int npcm_video_capres(struct npcm_video *video, unsigned int hor_res,