diff -ruN linux-5.10.237/drivers/media/test-drivers/vivid/vivid-vid-cap.c /home/elias/chromium-camera-exploit/vivid_padding_after_each_row_y16/vivid-vid-cap.c --- linux-5.10.237/drivers/media/test-drivers/vivid/vivid-vid-cap.c 2025-05-02 07:41:22.000000000 +0200 +++ /home/elias/chromium-camera-exploit/vivid_padding_after_each_row_y16/vivid-vid-cap.c 2025-09-15 09:15:34.387798153 +0200 @@ -46,7 +46,7 @@ }; /* The number of discrete webcam framesizes */ -#define VIVID_WEBCAM_SIZES 6 +#define VIVID_WEBCAM_SIZES 7 /* The number of discrete webcam frameintervals */ #define VIVID_WEBCAM_IVALS (VIVID_WEBCAM_SIZES * 2) @@ -55,6 +55,7 @@ { 320, 180 }, { 640, 360 }, { 640, 480 }, + { 848, 480 }, { 1280, 720 }, { 1920, 1080 }, { 3840, 2160 }, @@ -77,6 +78,8 @@ { 1, 40 }, { 1, 50 }, { 1, 60 }, + { 1, 120 }, + { 1, 240 }, }; static int vid_cap_queue_setup(struct vb2_queue *vq, @@ -113,14 +116,14 @@ if (*nplanes != buffers) return -EINVAL; for (p = 0; p < buffers; p++) { - if (sizes[p] < tpg_g_line_width(&dev->tpg, p) * h / + if (sizes[p] < tpg_g_bytesperline(&dev->tpg, p) * h / dev->fmt_cap->vdownsampling[p] + dev->fmt_cap->data_offset[p]) return -EINVAL; } } else { for (p = 0; p < buffers; p++) - sizes[p] = (tpg_g_line_width(&dev->tpg, p) * h) / + sizes[p] = (tpg_g_bytesperline(&dev->tpg, p) * h) / dev->fmt_cap->vdownsampling[p] + dev->fmt_cap->data_offset[p]; } @@ -158,7 +161,7 @@ return -EINVAL; } for (p = 0; p < buffers; p++) { - size = (tpg_g_line_width(&dev->tpg, p) * + size = (tpg_g_bytesperline(&dev->tpg, p) * dev->fmt_cap_rect.height) / dev->fmt_cap->vdownsampling[p] + dev->fmt_cap->data_offset[p]; @@ -466,6 +469,15 @@ tpg_s_video_aspect(&dev->tpg, vivid_get_video_aspect(dev)); tpg_s_pixel_aspect(&dev->tpg, vivid_get_pixel_aspect(dev)); tpg_update_mv_step(&dev->tpg); + + /* Apply 64-byte alignment to initial bytesperline */ + { + unsigned int p; + for (p = 0; p < tpg_g_buffers(&dev->tpg); p++) { + unsigned int aligned_bpl = ALIGN(tpg_g_bytesperline(&dev->tpg, p), 64); + tpg_s_bytesperline(&dev->tpg, p, aligned_bpl); + } + } } /* Map the field to something that is valid for the current input */ @@ -549,7 +561,7 @@ for (p = 0; p < mp->num_planes; p++) { mp->plane_fmt[p].bytesperline = tpg_g_bytesperline(&dev->tpg, p); mp->plane_fmt[p].sizeimage = - (tpg_g_line_width(&dev->tpg, p) * mp->height) / + (mp->plane_fmt[p].bytesperline * mp->height) / dev->fmt_cap->vdownsampling[p] + dev->fmt_cap->data_offset[p]; } @@ -630,6 +642,9 @@ pfmt[p].bytesperline = max_bpl; if (pfmt[p].bytesperline < bytesperline) pfmt[p].bytesperline = bytesperline; + + /* Always round up to 64-byte alignment */ + pfmt[p].bytesperline = ALIGN(pfmt[p].bytesperline, 64); pfmt[p].sizeimage = (pfmt[p].bytesperline * mp->height) / fmt->vdownsampling[p] + fmt->data_offset[p]; diff -ruN linux-5.10.237/drivers/media/test-drivers/vivid/vivid-vid-common.c /home/elias/chromium-camera-exploit/vivid_padding_after_each_row_y16/vivid-vid-common.c --- linux-5.10.237/drivers/media/test-drivers/vivid/vivid-vid-common.c 2025-05-02 07:41:22.000000000 +0200 +++ /home/elias/chromium-camera-exploit/vivid_padding_after_each_row_y16/vivid-vid-common.c 2025-09-15 09:15:34.387798153 +0200 @@ -910,14 +910,24 @@ int vivid_enum_fmt_vid(struct file *file, void *priv, struct v4l2_fmtdesc *f) { - struct vivid_dev *dev = video_drvdata(file); const struct vivid_fmt *fmt; + int i; - if (f->index >= ARRAY_SIZE(vivid_formats) - - (dev->multiplanar ? 0 : VIVID_MPLANAR_FORMATS)) + /* Only advertise Y16 format */ + if (f->index > 0) return -EINVAL; - fmt = &vivid_formats[f->index]; + /* Find Y16 format in the array */ + fmt = NULL; + for (i = 0; i < ARRAY_SIZE(vivid_formats); i++) { + if (vivid_formats[i].fourcc == V4L2_PIX_FMT_Y16) { + fmt = &vivid_formats[i]; + break; + } + } + + if (!fmt) + return -EINVAL; f->pixelformat = fmt->fourcc; diff -ruN linux-5.10.237/drivers/media/test-drivers/vivid/vivid-vid-out.c /home/elias/chromium-camera-exploit/vivid_padding_after_each_row_y16/vivid-vid-out.c --- linux-5.10.237/drivers/media/test-drivers/vivid/vivid-vid-out.c 2025-05-02 07:41:22.000000000 +0200 +++ /home/elias/chromium-camera-exploit/vivid_padding_after_each_row_y16/vivid-vid-out.c 2025-09-15 09:15:34.391798281 +0200 @@ -413,6 +413,9 @@ pfmt[p].bytesperline = max_bpl; if (pfmt[p].bytesperline < bytesperline) pfmt[p].bytesperline = bytesperline; + + /* Always round up to 64-byte alignment */ + pfmt[p].bytesperline = ALIGN(pfmt[p].bytesperline, 64); pfmt[p].sizeimage = (pfmt[p].bytesperline * mp->height) / fmt->vdownsampling[p] + fmt->data_offset[p];