de62fd9549c94c2de9779cce510aa1f7fa5058a6
[openwrt/staging/neocturne.git] /
1 From 38822ea8817873a2cf74353ef6ad8e363e3dea70 Mon Sep 17 00:00:00 2001
2 From: Dave Stevenson <dave.stevenson@raspberrypi.com>
3 Date: Thu, 3 Nov 2022 13:45:37 +0000
4 Subject: [PATCH] vc04_services: bcm2835_codec: Allow larger images
5 through the ISP
6
7 Whilst the codecs are restricted to 1920x1080 / 1080x1920, the ISP
8 isn't, but the limits advertised via V4L2 was 1920x1920 for all
9 roles.
10
11 Increase the limit to 16k x 16k for the ISP.
12
13 Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
14 ---
15 .../bcm2835-codec/bcm2835-v4l2-codec.c | 31 ++++++++++++++-----
16 1 file changed, 23 insertions(+), 8 deletions(-)
17
18 --- a/drivers/staging/vc04_services/bcm2835-codec/bcm2835-v4l2-codec.c
19 +++ b/drivers/staging/vc04_services/bcm2835-codec/bcm2835-v4l2-codec.c
20 @@ -119,8 +119,10 @@ static const char * const components[] =
21
22 #define MIN_W 32
23 #define MIN_H 32
24 -#define MAX_W 1920
25 -#define MAX_H 1920
26 +#define MAX_W_CODEC 1920
27 +#define MAX_H_CODEC 1920
28 +#define MAX_W_ISP 16384
29 +#define MAX_H_ISP 16384
30 #define BPL_ALIGN 32
31 /*
32 * The decoder spec supports the V4L2_EVENT_SOURCE_CHANGE event, but the docs
33 @@ -686,6 +688,13 @@ struct bcm2835_codec_dev {
34 /* The list of formats supported on input and output queues. */
35 struct bcm2835_codec_fmt_list supported_fmts[2];
36
37 + /*
38 + * Max size supported varies based on role. Store during
39 + * bcm2835_codec_create for use later.
40 + */
41 + unsigned int max_w;
42 + unsigned int max_h;
43 +
44 struct vchiq_mmal_instance *instance;
45
46 struct v4l2_m2m_dev *m2m_dev;
47 @@ -1471,10 +1480,10 @@ static int vidioc_try_fmt(struct bcm2835
48 * The V4L2 specification requires the driver to correct the format
49 * struct if any of the dimensions is unsupported
50 */
51 - if (f->fmt.pix_mp.width > MAX_W)
52 - f->fmt.pix_mp.width = MAX_W;
53 - if (f->fmt.pix_mp.height > MAX_H)
54 - f->fmt.pix_mp.height = MAX_H;
55 + if (f->fmt.pix_mp.width > ctx->dev->max_w)
56 + f->fmt.pix_mp.width = ctx->dev->max_w;
57 + if (f->fmt.pix_mp.height > ctx->dev->max_h)
58 + f->fmt.pix_mp.height = ctx->dev->max_h;
59
60 if (!(fmt->flags & V4L2_FMT_FLAG_COMPRESSED)) {
61 /* Only clip min w/h on capture. Treat 0x0 as unknown. */
62 @@ -2528,6 +2537,7 @@ static int vidioc_encoder_cmd(struct fil
63 static int vidioc_enum_framesizes(struct file *file, void *fh,
64 struct v4l2_frmsizeenum *fsize)
65 {
66 + struct bcm2835_codec_ctx *ctx = file2ctx(file);
67 struct bcm2835_codec_fmt *fmt;
68
69 fmt = find_format_pix_fmt(fsize->pixel_format, file2ctx(file)->dev,
70 @@ -2546,10 +2556,10 @@ static int vidioc_enum_framesizes(struct
71 fsize->type = V4L2_FRMSIZE_TYPE_STEPWISE;
72
73 fsize->stepwise.min_width = MIN_W;
74 - fsize->stepwise.max_width = MAX_W;
75 + fsize->stepwise.max_width = ctx->dev->max_w;
76 fsize->stepwise.step_width = 2;
77 fsize->stepwise.min_height = MIN_H;
78 - fsize->stepwise.max_height = MAX_H;
79 + fsize->stepwise.max_height = ctx->dev->max_h;
80 fsize->stepwise.step_height = 2;
81
82 return 0;
83 @@ -3623,6 +3633,9 @@ static int bcm2835_codec_create(struct b
84 if (ret)
85 goto vchiq_finalise;
86
87 + dev->max_w = MAX_W_CODEC;
88 + dev->max_h = MAX_H_CODEC;
89 +
90 switch (role) {
91 case DECODE:
92 v4l2_disable_ioctl(vfd, VIDIOC_ENCODER_CMD);
93 @@ -3645,6 +3658,8 @@ static int bcm2835_codec_create(struct b
94 v4l2_disable_ioctl(vfd, VIDIOC_G_PARM);
95 function = MEDIA_ENT_F_PROC_VIDEO_SCALER;
96 video_nr = isp_video_nr;
97 + dev->max_w = MAX_W_ISP;
98 + dev->max_h = MAX_H_ISP;
99 break;
100 case DEINTERLACE:
101 v4l2_disable_ioctl(vfd, VIDIOC_DECODER_CMD);