Skip to contentSkip to conversation

media: imx-jpeg: Encoder support to set jpeg quality

PATCH Superseded Ming Qian 2 participants 2 messages Apr 22, 2022

Subsystems (3)

v3 of 5 Superseded Latest is v5 →

lore
Share & tools
lore

Ming Qian

author
#0 lore raw

PATCH v3 1/1 media: imx-jpeg: Encoder support to set jpeg quality

Implement V4L2_CID_JPEG_COMPRESSION_QUALITY
to set jpeg quality

---
v3
- put this v3 information below the --- line

v2
- free ctrl handler if error is set and return error

---
 .../media/platform/nxp/imx-jpeg/mxc-jpeg-hw.c | 11 +++-
 .../media/platform/nxp/imx-jpeg/mxc-jpeg-hw.h |  1 +
 .../media/platform/nxp/imx-jpeg/mxc-jpeg.c    | 57 +++++++++++++++++++
 .../media/platform/nxp/imx-jpeg/mxc-jpeg.h    |  2 +
 4 files changed, 68 insertions(+), 3 deletions(-)
drivers/media/platform/nxp/imx-jpeg/mxc-jpeg-hw.c +8 -3
index 29c604b1b179..c482228262a3 100644
@@ -100,9 +100,6 @@ void mxc_jpeg_enc_mode_conf(struct device *dev, void __iomem *reg)
 
 	/* all markers and segments */
 	writel(0x3ff, reg + CAST_CFG_MODE);
-
-	/* quality factor */
-	writel(0x4b, reg + CAST_QUALITY);
 }
 
 void mxc_jpeg_enc_mode_go(struct device *dev, void __iomem *reg)
@@ -114,6 +111,14 @@ void mxc_jpeg_enc_mode_go(struct device *dev, void __iomem *reg)
 	writel(0x140, reg + CAST_MODE);
 }
 
+void mxc_jpeg_enc_set_quality(struct device *dev, void __iomem *reg, u8 quality)
+{
+	dev_dbg(dev, "CAST Encoder Quality %d...\n", quality);
+
+	/* quality factor */
+	writel(quality, reg + CAST_QUALITY);
+}
+
 void mxc_jpeg_dec_mode_go(struct device *dev, void __iomem *reg)
 {
 	dev_dbg(dev, "CAST Decoder GO...\n");
drivers/media/platform/nxp/imx-jpeg/mxc-jpeg-hw.h +1 -0
index ae70d3a0dc24..356e40140987 100644
@@ -119,6 +119,7 @@ int mxc_jpeg_enable(void __iomem *reg);
 void wait_frmdone(struct device *dev, void __iomem *reg);
 void mxc_jpeg_enc_mode_conf(struct device *dev, void __iomem *reg);
 void mxc_jpeg_enc_mode_go(struct device *dev, void __iomem *reg);
+void mxc_jpeg_enc_set_quality(struct device *dev, void __iomem *reg, u8 quality);
 void mxc_jpeg_dec_mode_go(struct device *dev, void __iomem *reg);
 int mxc_jpeg_get_slot(void __iomem *reg);
 u32 mxc_jpeg_get_offset(void __iomem *reg, int slot);
drivers/media/platform/nxp/imx-jpeg/mxc-jpeg.c +57 -0

93 lines not on this page · raw message

drivers/media/platform/nxp/imx-jpeg/mxc-jpeg.h +2 -0
index 9ae56e6e0fbe..9c9da32b2125 100644
@@ -96,6 +96,8 @@ struct mxc_jpeg_ctx {
 	unsigned int			slot;
 	unsigned int			source_change;
 	bool				header_parsed;
+	struct v4l2_ctrl_handler	ctrl_handler;
+	u8				jpeg_quality;
 };
 
 struct mxc_jpeg_slot_data {
Signature · 1 line
2.35.1
reviewer
#1 lore raw
Quoted 10 lines · Ming Qian

Implement V4L2_CID_JPEG_COMPRESSION_QUALITY
to set jpeg quality

---
v3
- put this v3 information below the --- line

v2
- free ctrl handler if error is set and return error

Wrong placement.

Quoted 3 lines

---

It is after the Signed-off-by and this --- line that you should put the version history.