Skip to content

Commit de4d7e4

Browse files
6by9popcornmix
authored andcommitted
media: bcm2835-unicam: Retain packing information on G_FMT
The change to retrieve the pixel format always on g_fmt didn't check whether the native or unpacked version of the format had been requested, and always returned the packed one. Correct this so that the packing setting is retained whereever possible. Fixes "9d59e89 media: bcm2835-unicam: Re-fetch mbus code from subdev on a g_fmt call" Signed-off-by: Dave Stevenson <[email protected]>
1 parent 2e5f704 commit de4d7e4

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

drivers/media/platform/bcm2835/bcm2835-unicam.c

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -974,8 +974,23 @@ static int unicam_g_fmt_vid_cap(struct file *file, void *priv,
974974
if (!fmt)
975975
return -EINVAL;
976976

977-
node->fmt = fmt;
978-
node->v_fmt.fmt.pix.pixelformat = fmt->fourcc;
977+
if (node->fmt != fmt) {
978+
/*
979+
* The sensor format has changed so the pixelformat needs to
980+
* be updated. Try and retain the packed/unpacked choice if
981+
* at all possible.
982+
*/
983+
if (node->fmt->repacked_fourcc ==
984+
node->v_fmt.fmt.pix.pixelformat)
985+
/* Using the repacked format */
986+
node->v_fmt.fmt.pix.pixelformat = fmt->repacked_fourcc;
987+
else
988+
/* Using the native format */
989+
node->v_fmt.fmt.pix.pixelformat = fmt->fourcc;
990+
991+
node->fmt = fmt;
992+
}
993+
979994
*f = node->v_fmt;
980995

981996
return 0;

0 commit comments

Comments
 (0)