linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Corentin Labbe <clabbe@baylibre.com>
To: gregkh@linuxfoundation.org, laurent.pinchart@skynet.be,
	mchehab@kernel.org
Cc: devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org,
	linux-media@vger.kernel.org, Corentin Labbe <clabbe@baylibre.com>
Subject: [PATCH RFT/RFC 19/49] staging: media: zoran: move jpg_settings out of zoran_fh
Date: Mon, 21 Sep 2020 10:19:54 +0000	[thread overview]
Message-ID: <1600683624-5863-20-git-send-email-clabbe@baylibre.com> (raw)
In-Reply-To: <1600683624-5863-1-git-send-email-clabbe@baylibre.com>

We need to get rid of zoran_fh, so move the jpg_settings directly in the
zoran structure.
Signed-off-by: Corentin Labbe <clabbe@baylibre.com>
---
 drivers/staging/media/zoran/zoran.h        |   2 -
 drivers/staging/media/zoran/zoran_driver.c | 103 ++++++++++-----------
 2 files changed, 47 insertions(+), 58 deletions(-)

diff --git a/drivers/staging/media/zoran/zoran.h b/drivers/staging/media/zoran/zoran.h
index a529b49888c6..7e6e03563a2a 100644
--- a/drivers/staging/media/zoran/zoran.h
+++ b/drivers/staging/media/zoran/zoran.h
@@ -216,8 +216,6 @@ struct zoran_fh {
 	enum zoran_lock_activity overlay_active;/* feature currently in use? */
 
 	struct zoran_buffer_col buffers;	/* buffers' info */
-
-	struct zoran_jpg_settings jpg_settings;	/* structure with a lot of things to play with */
 };
 
 struct card_info {
diff --git a/drivers/staging/media/zoran/zoran_driver.c b/drivers/staging/media/zoran/zoran_driver.c
index 984f1dde99d2..f0ceda9a3d44 100644
--- a/drivers/staging/media/zoran/zoran_driver.c
+++ b/drivers/staging/media/zoran/zoran_driver.c
@@ -587,9 +587,7 @@ static int zoran_jpg_queue_frame(struct zoran_fh *fh, int num,
 	}
 
 	/* what is the codec mode right now? */
-	if (zr->codec_mode == BUZ_MODE_IDLE) {
-		zr->jpg_settings = fh->jpg_settings;
-	} else if (zr->codec_mode != mode) {
+	if (zr->codec_mode != BUZ_MODE_IDLE && zr->codec_mode != mode) {
 		/* wrong codec mode active - invalid */
 		pci_err(zr->pci_dev, "%s - codec in wrong mode\n", __func__);
 		return -EINVAL;
@@ -751,9 +749,6 @@ static void zoran_open_init_session(struct zoran_fh *fh)
 	fh->overlay_settings.format = zr->overlay_settings.format;
 	fh->overlay_active = ZORAN_FREE;
 
-	/* jpg settings */
-	fh->jpg_settings = zr->jpg_settings;
-
 	/* buffers */
 	memset(&fh->buffers, 0, sizeof(fh->buffers));
 	for (i = 0; i < MAX_FRAME; i++) {
@@ -1237,11 +1232,11 @@ static int zoran_v4l2_buffer_status(struct zoran_fh *fh,
 		}
 
 		/* which fields are these? */
-		if (fh->jpg_settings.TmpDcm != 1)
-			buf->field = fh->jpg_settings.odd_even ?
+		if (zr->jpg_settings.TmpDcm != 1)
+			buf->field = zr->jpg_settings.odd_even ?
 				V4L2_FIELD_TOP : V4L2_FIELD_BOTTOM;
 		else
-			buf->field = fh->jpg_settings.odd_even ?
+			buf->field = zr->jpg_settings.odd_even ?
 				V4L2_FIELD_SEQ_TB : V4L2_FIELD_SEQ_BT;
 
 		break;
@@ -1389,18 +1384,18 @@ static int zoran_enum_fmt_vid_overlay(struct file *file, void *__fh,
 
 static int zoran_g_fmt_vid_out(struct file *file, void *__fh, struct v4l2_format *fmt)
 {
-	struct zoran_fh *fh = __fh;
+	struct zoran *zr = video_drvdata(file);
 
-	fmt->fmt.pix.width = fh->jpg_settings.img_width / fh->jpg_settings.HorDcm;
-	fmt->fmt.pix.height = fh->jpg_settings.img_height * 2 /
-		(fh->jpg_settings.VerDcm * fh->jpg_settings.TmpDcm);
-	fmt->fmt.pix.sizeimage = zoran_v4l2_calc_bufsize(&fh->jpg_settings);
+	fmt->fmt.pix.width = zr->jpg_settings.img_width / zr->jpg_settings.HorDcm;
+	fmt->fmt.pix.height = zr->jpg_settings.img_height * 2 /
+		(zr->jpg_settings.VerDcm * zr->jpg_settings.TmpDcm);
+	fmt->fmt.pix.sizeimage = zoran_v4l2_calc_bufsize(&zr->jpg_settings);
 	fmt->fmt.pix.pixelformat = V4L2_PIX_FMT_MJPEG;
-	if (fh->jpg_settings.TmpDcm == 1)
-		fmt->fmt.pix.field = (fh->jpg_settings.odd_even ?
+	if (zr->jpg_settings.TmpDcm == 1)
+		fmt->fmt.pix.field = (zr->jpg_settings.odd_even ?
 				V4L2_FIELD_SEQ_TB : V4L2_FIELD_SEQ_BT);
 	else
-		fmt->fmt.pix.field = (fh->jpg_settings.odd_even ?
+		fmt->fmt.pix.field = (zr->jpg_settings.odd_even ?
 				V4L2_FIELD_TOP : V4L2_FIELD_BOTTOM);
 	fmt->fmt.pix.bytesperline = 0;
 	fmt->fmt.pix.colorspace = V4L2_COLORSPACE_SMPTE170M;
@@ -1468,15 +1463,14 @@ static int zoran_try_fmt_vid_overlay(struct file *file, void *__fh,
 static int zoran_try_fmt_vid_out(struct file *file, void *__fh,
 				 struct v4l2_format *fmt)
 {
-	struct zoran_fh *fh = __fh;
-	struct zoran *zr = fh->zr;
+	struct zoran *zr = video_drvdata(file);
 	struct zoran_jpg_settings settings;
 	int res = 0;
 
 	if (fmt->fmt.pix.pixelformat != V4L2_PIX_FMT_MJPEG)
 		return -EINVAL;
 
-	settings = fh->jpg_settings;
+	settings = zr->jpg_settings;
 
 	/* we actually need to set 'real' parameters now */
 	if ((fmt->fmt.pix.height * 2) > BUZ_MAX_HEIGHT)
@@ -1484,13 +1478,13 @@ static int zoran_try_fmt_vid_out(struct file *file, void *__fh,
 	else
 		settings.TmpDcm = 2;
 	settings.decimation = 0;
-	if (fmt->fmt.pix.height <= fh->jpg_settings.img_height / 2)
+	if (fmt->fmt.pix.height <= zr->jpg_settings.img_height / 2)
 		settings.VerDcm = 2;
 	else
 		settings.VerDcm = 1;
-	if (fmt->fmt.pix.width <= fh->jpg_settings.img_width / 4)
+	if (fmt->fmt.pix.width <= zr->jpg_settings.img_width / 4)
 		settings.HorDcm = 4;
-	else if (fmt->fmt.pix.width <= fh->jpg_settings.img_width / 2)
+	else if (fmt->fmt.pix.width <= zr->jpg_settings.img_width / 2)
 		settings.HorDcm = 2;
 	else
 		settings.HorDcm = 1;
@@ -1517,10 +1511,10 @@ static int zoran_try_fmt_vid_out(struct file *file, void *__fh,
 	fmt->fmt.pix.height = settings.img_height * 2 /
 		(settings.TmpDcm * settings.VerDcm);
 	if (settings.TmpDcm == 1)
-		fmt->fmt.pix.field = (fh->jpg_settings.odd_even ?
+		fmt->fmt.pix.field = (zr->jpg_settings.odd_even ?
 				V4L2_FIELD_SEQ_TB : V4L2_FIELD_SEQ_BT);
 	else
-		fmt->fmt.pix.field = (fh->jpg_settings.odd_even ?
+		fmt->fmt.pix.field = (zr->jpg_settings.odd_even ?
 				V4L2_FIELD_TOP : V4L2_FIELD_BOTTOM);
 
 	fmt->fmt.pix.sizeimage = zoran_v4l2_calc_bufsize(&settings);
@@ -1594,7 +1588,7 @@ static int zoran_s_fmt_vid_out(struct file *file, void *__fh, struct v4l2_format
 		return res;
 	}
 
-	settings = fh->jpg_settings;
+	settings = zr->jpg_settings;
 
 	/* we actually need to set 'real' parameters now */
 	if (fmt->fmt.pix.height * 2 > BUZ_MAX_HEIGHT)
@@ -1602,13 +1596,13 @@ static int zoran_s_fmt_vid_out(struct file *file, void *__fh, struct v4l2_format
 	else
 		settings.TmpDcm = 2;
 	settings.decimation = 0;
-	if (fmt->fmt.pix.height <= fh->jpg_settings.img_height / 2)
+	if (fmt->fmt.pix.height <= zr->jpg_settings.img_height / 2)
 		settings.VerDcm = 2;
 	else
 		settings.VerDcm = 1;
-	if (fmt->fmt.pix.width <= fh->jpg_settings.img_width / 4)
+	if (fmt->fmt.pix.width <= zr->jpg_settings.img_width / 4)
 		settings.HorDcm = 4;
-	else if (fmt->fmt.pix.width <= fh->jpg_settings.img_width / 2)
+	else if (fmt->fmt.pix.width <= zr->jpg_settings.img_width / 2)
 		settings.HorDcm = 2;
 	else
 		settings.HorDcm = 1;
@@ -1631,19 +1625,19 @@ static int zoran_s_fmt_vid_out(struct file *file, void *__fh, struct v4l2_format
 		return res;
 
 	/* it's ok, so set them */
-	fh->jpg_settings = settings;
+	zr->jpg_settings = settings;
 
 	map_mode_jpg(fh, fmt->type == V4L2_BUF_TYPE_VIDEO_OUTPUT);
-	zr->buffer_size = zoran_v4l2_calc_bufsize(&fh->jpg_settings);
+	zr->buffer_size = zoran_v4l2_calc_bufsize(&zr->jpg_settings);
 
 	/* tell the user what we actually did */
 	fmt->fmt.pix.width = settings.img_width / settings.HorDcm;
 	fmt->fmt.pix.height = settings.img_height * 2 / (settings.TmpDcm * settings.VerDcm);
 	if (settings.TmpDcm == 1)
-		fmt->fmt.pix.field = (fh->jpg_settings.odd_even ?
+		fmt->fmt.pix.field = (zr->jpg_settings.odd_even ?
 				V4L2_FIELD_SEQ_TB : V4L2_FIELD_SEQ_BT);
 	else
-		fmt->fmt.pix.field = (fh->jpg_settings.odd_even ?
+		fmt->fmt.pix.field = (zr->jpg_settings.odd_even ?
 				V4L2_FIELD_TOP : V4L2_FIELD_BOTTOM);
 	fmt->fmt.pix.bytesperline = 0;
 	fmt->fmt.pix.sizeimage = zr->buffer_size;
@@ -1798,7 +1792,7 @@ static int zoran_reqbufs(struct file *file, void *__fh, struct v4l2_requestbuffe
 		/* The next mmap will map the MJPEG buffers */
 		map_mode_jpg(fh, req->type == V4L2_BUF_TYPE_VIDEO_OUTPUT);
 		fh->buffers.num_buffers = req->count;
-		zr->buffer_size = zoran_v4l2_calc_bufsize(&fh->jpg_settings);
+		zr->buffer_size = zoran_v4l2_calc_bufsize(&zr->jpg_settings);
 
 		if (jpg_fbuffer_alloc(fh)) {
 			res = -ENOMEM;
@@ -2162,10 +2156,10 @@ static int zoran_g_selection(struct file *file, void *__fh, struct v4l2_selectio
 
 	switch (sel->target) {
 	case V4L2_SEL_TGT_CROP:
-		sel->r.top = fh->jpg_settings.img_y;
-		sel->r.left = fh->jpg_settings.img_x;
-		sel->r.width = fh->jpg_settings.img_width;
-		sel->r.height = fh->jpg_settings.img_height;
+		sel->r.top = zr->jpg_settings.img_y;
+		sel->r.left = zr->jpg_settings.img_x;
+		sel->r.width = zr->jpg_settings.img_width;
+		sel->r.height = zr->jpg_settings.img_height;
 		break;
 	case V4L2_SEL_TGT_CROP_DEFAULT:
 		sel->r.top = sel->r.left = 0;
@@ -2202,7 +2196,7 @@ static int zoran_s_selection(struct file *file, void *__fh, struct v4l2_selectio
 		return -EINVAL;
 	}
 
-	settings = fh->jpg_settings;
+	settings = zr->jpg_settings;
 
 	if (fh->buffers.allocated) {
 		pci_err(zr->pci_dev, "VIDIOC_S_SELECTION - cannot change settings while active\n");
@@ -2221,28 +2215,25 @@ static int zoran_s_selection(struct file *file, void *__fh, struct v4l2_selectio
 		return res;
 
 	/* accept */
-	fh->jpg_settings = settings;
+	zr->jpg_settings = settings;
 	return res;
 }
 
 static int zoran_g_jpegcomp(struct file *file, void *__fh, struct v4l2_jpegcompression *params)
 {
-	struct zoran_fh *fh = __fh;
+	struct zoran *zr = video_drvdata(file);
 
 	memset(params, 0, sizeof(*params));
 
-	params->quality = fh->jpg_settings.jpg_comp.quality;
-	params->APPn = fh->jpg_settings.jpg_comp.APPn;
-	memcpy(params->APP_data,
-	       fh->jpg_settings.jpg_comp.APP_data,
-	       fh->jpg_settings.jpg_comp.APP_len);
-	params->APP_len = fh->jpg_settings.jpg_comp.APP_len;
-	memcpy(params->COM_data,
-	       fh->jpg_settings.jpg_comp.COM_data,
-	       fh->jpg_settings.jpg_comp.COM_len);
-	params->COM_len = fh->jpg_settings.jpg_comp.COM_len;
-	params->jpeg_markers =
-	    fh->jpg_settings.jpg_comp.jpeg_markers;
+	params->quality = zr->jpg_settings.jpg_comp.quality;
+	params->APPn = zr->jpg_settings.jpg_comp.APPn;
+	memcpy(params->APP_data, zr->jpg_settings.jpg_comp.APP_data,
+	       zr->jpg_settings.jpg_comp.APP_len);
+	params->APP_len = zr->jpg_settings.jpg_comp.APP_len;
+	memcpy(params->COM_data, zr->jpg_settings.jpg_comp.COM_data,
+	       zr->jpg_settings.jpg_comp.COM_len);
+	params->COM_len = zr->jpg_settings.jpg_comp.COM_len;
+	params->jpeg_markers = zr->jpg_settings.jpg_comp.jpeg_markers;
 
 	return 0;
 }
@@ -2255,7 +2246,7 @@ static int zoran_s_jpegcomp(struct file *file, void *__fh,
 	int res = 0;
 	struct zoran_jpg_settings settings;
 
-	settings = fh->jpg_settings;
+	settings = zr->jpg_settings;
 
 	settings.jpg_comp = *params;
 
@@ -2269,8 +2260,8 @@ static int zoran_s_jpegcomp(struct file *file, void *__fh,
 	if (res)
 		return res;
 	if (!fh->buffers.allocated)
-		zr->buffer_size = zoran_v4l2_calc_bufsize(&fh->jpg_settings);
-	fh->jpg_settings.jpg_comp = settings.jpg_comp;
+		zr->buffer_size = zoran_v4l2_calc_bufsize(&zr->jpg_settings);
+	zr->jpg_settings.jpg_comp = settings.jpg_comp;
 	return res;
 }
 
-- 
2.26.2


  parent reply	other threads:[~2020-09-21 10:22 UTC|newest]

Thread overview: 56+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-21 10:19 [PATCH RFT/RFC 00/49] staging: media: bring back zoran driver Corentin Labbe
2020-09-21 10:19 ` [PATCH RFT/RFC 01/49] staging: media: Revert "media: zoran: remove deprecated driver" Corentin Labbe
2020-09-22  5:16   ` Christoph Hellwig
2020-09-22 19:15     ` LABBE Corentin
2020-09-21 10:19 ` [PATCH RFT/RFC 02/49] MAINTAINERS: change maintainer of the zoran driver Corentin Labbe
2020-09-21 10:19 ` [PATCH RFT/RFC 03/49] staging: media: zoran: datasheet is no longer available from zoran.com Corentin Labbe
2020-09-21 10:19 ` [PATCH RFT/RFC 04/49] staging: media: zoran: Documentation: fix typo Corentin Labbe
2020-09-21 10:19 ` [PATCH RFT/RFC 05/49] staging: media: zoran: fix checkpatch issue Corentin Labbe
2020-09-21 10:19 ` [PATCH RFT/RFC 06/49] staging: media: zoran: unsplit lines Corentin Labbe
2020-09-22  5:13   ` Christoph Hellwig
2020-09-21 10:19 ` [PATCH RFT/RFC 07/49] staging: media: zoran: do not forward declare zr36057_init_vfe Corentin Labbe
2020-09-21 10:19 ` [PATCH RFT/RFC 08/49] staging: media: zoran: convert all error dprintk to pci_err/pr_err Corentin Labbe
2020-09-21 10:19 ` [PATCH RFT/RFC 09/49] staging: media: zoran: convert dprintk warn Corentin Labbe
2020-09-21 10:19 ` [PATCH RFT/RFC 10/49] staging: media: zoran: convert dprintk info to pci_info Corentin Labbe
2020-09-21 10:19 ` [PATCH RFT/RFC 11/49] staging: media: zoran: convert dprintk debug Corentin Labbe
2020-09-21 10:19 ` [PATCH RFT/RFC 12/49] staging: media: zoran: zoran_device.c: convert pr_x to pci_x Corentin Labbe
2020-09-21 10:19 ` [PATCH RFT/RFC 13/49] staging: media: zoran: remove proc_fs Corentin Labbe
2020-09-21 10:19 ` [PATCH RFT/RFC 14/49] staging: media: zoran: use VFL_TYPE_VIDEO Corentin Labbe
2020-09-21 10:19 ` [PATCH RFT/RFC 15/49] staging: media: zoran: use v4l2_buffer_set_timestamp Corentin Labbe
2020-09-21 10:19 ` [PATCH RFT/RFC 16/49] staging: media: zoran: do not print random guest 0 Corentin Labbe
2020-09-21 10:19 ` [PATCH RFT/RFC 17/49] staging: media: zoran: move buffer_size out of zoran_fh Corentin Labbe
2020-09-21 10:19 ` [PATCH RFT/RFC 18/49] staging: media: zoran: move v4l_settings " Corentin Labbe
2020-09-21 10:19 ` Corentin Labbe [this message]
2020-09-21 10:19 ` [PATCH RFT/RFC 20/49] staging: media: zoran: move overlay_settings " Corentin Labbe
2020-09-21 10:19 ` [PATCH RFT/RFC 21/49] staging: media: zoran: Use video_drvdata to get struct zoran Corentin Labbe
2020-09-21 10:19 ` [PATCH RFT/RFC 22/49] staging: media: zoran: Change zoran_v4l_set_format parameter from zoran_fh to zoran Corentin Labbe
2020-09-21 10:19 ` [PATCH RFT/RFC 23/49] staging: media: zoran: remove overlay Corentin Labbe
2020-09-21 10:19 ` [PATCH RFT/RFC 24/49] staging: media: zoran: Use DMA coherent for stat_com Corentin Labbe
2020-09-22  5:14   ` Christoph Hellwig
2020-09-21 10:20 ` [PATCH RFT/RFC 25/49] staging: media: zoran: use ZR_NORM Corentin Labbe
2020-09-21 10:20 ` [PATCH RFT/RFC 26/49] staging: media: zoran: zoran does not support STD_ALL Corentin Labbe
2020-09-21 10:20 ` [PATCH RFT/RFC 27/49] staging: media: zoran: convert irq to pci irq Corentin Labbe
2020-09-21 10:20 ` [PATCH RFT/RFC 28/49] staging: media: zoran: convert zoran alloc to devm Corentin Labbe
2020-09-21 10:20 ` [PATCH RFT/RFC 29/49] staging: media: zoran: convert mdelay to udelay Corentin Labbe
2020-09-21 10:20 ` [PATCH RFT/RFC 30/49] staging: media: zoran: use devm for videocodec_master alloc Corentin Labbe
2020-09-21 10:20 ` [PATCH RFT/RFC 31/49] staging: media: zoran: use pci_request_regions Corentin Labbe
2020-09-21 10:20 ` [PATCH RFT/RFC 32/49] staging: media: zoran: use devm_ioremap Corentin Labbe
2020-09-21 10:20 ` [PATCH RFT/RFC 33/49] staging: media: zoran: add stat_com buffer Corentin Labbe
2020-09-21 10:20 ` [PATCH RFT/RFC 34/49] staging: media: zoran: constify struct tvnorm Corentin Labbe
2020-09-21 10:20 ` [PATCH RFT/RFC 35/49] staging: media: zoran: constify codec_name Corentin Labbe
2020-09-21 10:20 ` [PATCH RFT/RFC 36/49] staging: media: zoran: Add more check for compliance Corentin Labbe
2020-09-21 10:20 ` [PATCH RFT/RFC 37/49] staging: media: zoran: add fallthrough keyword Corentin Labbe
2020-09-21 10:59   ` Dan Carpenter
2020-09-24 18:03     ` LABBE Corentin
2020-09-21 10:20 ` [PATCH RFT/RFC 38/49] staging: media: zoran: Add vb_queue Corentin Labbe
2020-09-21 10:20 ` [PATCH RFT/RFC 39/49] staging: media: zoran: disable output Corentin Labbe
2020-09-21 10:20 ` [PATCH RFT/RFC 40/49] staging: media: zoran: device support only 32bit DMA address Corentin Labbe
2020-09-21 10:20 ` [PATCH RFT/RFC 41/49] staging: media: zoran: enable makefile Corentin Labbe
2020-09-21 10:20 ` [PATCH RFT/RFC 42/49] staging: media: zoran: remove framebuffer support Corentin Labbe
2020-09-21 10:20 ` [PATCH RFT/RFC 43/49] staging: media: zoran: add vidioc_g_parm Corentin Labbe
2020-09-21 10:20 ` [PATCH RFT/RFC 44/49] staging: media: zoran: remove test_interrupts Corentin Labbe
2020-09-21 10:20 ` [PATCH RFT/RFC 45/49] staging: media: zoran: fix use of buffer_size and sizeimage Corentin Labbe
2020-09-21 10:20 ` [PATCH RFT/RFC 46/49] staging: media: zoran: fix some compliance test Corentin Labbe
2020-09-21 10:20 ` [PATCH RFT/RFC 47/49] staging: media: zoran: remove deprecated .vidioc_g_jpegcomp Corentin Labbe
2020-09-21 10:20 ` [PATCH RFT/RFC 48/49] staging: media: zoran: convert to vb2 Corentin Labbe
2020-09-21 10:20 ` [PATCH RFT/RFC 49/49] staging: media: zoran: update TODO Corentin Labbe

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1600683624-5863-20-git-send-email-clabbe@baylibre.com \
    --to=clabbe@baylibre.com \
    --cc=devel@driverdev.osuosl.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=laurent.pinchart@skynet.be \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=mchehab@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).