]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
media: nuvoton: npcm-video: Prevent returning unsupported resolutions
authorMichael Chang <zhang971090220@gmail.com>
Tue, 8 Apr 2025 05:54:54 +0000 (13:54 +0800)
committerHans Verkuil <hverkuil@xs4all.nl>
Fri, 25 Apr 2025 13:14:33 +0000 (15:14 +0200)
To restrict the returned resolution due to Nuvoton SoC hardware
limitations.

Signed-off-by: Michael Chang <zhang971090220@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
drivers/media/platform/nuvoton/npcm-video.c

index 3022fdcf66ec7ae9281da73617eb7b3ba027defe..44e904e61801e8c3b0d3bb8ca83aef0a50fc5992 100644 (file)
@@ -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,