Skip to contentSkip to conversation

em28xx: add image quality bridge controls

PATCH New Frank Schäfer 1 participant 5 messages Feb 15, 2013

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

v2 cover em28xx: add image quality bridge controls

The first two patches remove unused code.
The third patch makes sure that the same image quality default settings are used everywhere in the code.
The fourth patch finally adds the following image quality bridge controls:
- contrast
- brightness
- saturation
- blue balance
- red balance
- sharpness

Tested with the following devices:
"Terratec Cinergy 200 USB"
"Hauppauge HVR-900"
"SilverCrest 1.3MPix webcam"
"Hauppauge WinTV USB2"
"Speedlink VAD Laplace webcam"

Changes in v2:
- fixed a tab-space issue in patch 3

Frank Schäfer (4):
em28xx: remove unused image quality control functions
em28xx: remove unused ac97 v4l2_ctrl_handler
em28xx: introduce #defines for the image quality default settings
em28xx: add image quality bridge controls

 drivers/media/usb/em28xx/em28xx-cards.c |    7 +---
 drivers/media/usb/em28xx/em28xx-core.c  |   12 +++---
 drivers/media/usb/em28xx/em28xx-reg.h   |   23 ++++++++---
 drivers/media/usb/em28xx/em28xx-video.c |   58 +++++++++++++++++++++++++-
 drivers/media/usb/em28xx/em28xx.h       |   68 -------------------------------

5 Dateien geändert, 80 Zeilen hinzugefügt(+), 88 Zeilen entfernt(-)

Signature · 1 line
1.7.10.4
#1 lore raw

PATCH v2 1/4 em28xx: remove unused image quality control functions

---
 drivers/media/usb/em28xx/em28xx.h |   66 -------------------------------------

1 Datei geändert, 66 Zeilen entfernt(-)

drivers/media/usb/em28xx/em28xx.h +0 -66
index 5f0b2c5..6a9e3e1 100644
@@ -744,72 +744,6 @@ static inline int em28xx_compression_disable(struct em28xx *dev)
 	return em28xx_write_reg(dev, EM28XX_R26_COMPR, 0x00);
 }
 
-static inline int em28xx_contrast_get(struct em28xx *dev)
-{
-	return em28xx_read_reg(dev, EM28XX_R20_YGAIN) & 0x1f;
-}
-
-static inline int em28xx_brightness_get(struct em28xx *dev)
-{
-	return em28xx_read_reg(dev, EM28XX_R21_YOFFSET);
-}
-
-static inline int em28xx_saturation_get(struct em28xx *dev)
-{
-	return em28xx_read_reg(dev, EM28XX_R22_UVGAIN) & 0x1f;
-}
-
-static inline int em28xx_u_balance_get(struct em28xx *dev)
-{
-	return em28xx_read_reg(dev, EM28XX_R23_UOFFSET);
-}
-
-static inline int em28xx_v_balance_get(struct em28xx *dev)
-{
-	return em28xx_read_reg(dev, EM28XX_R24_VOFFSET);
-}
-
-static inline int em28xx_gamma_get(struct em28xx *dev)
-{
-	return em28xx_read_reg(dev, EM28XX_R14_GAMMA) & 0x3f;
-}
-
-static inline int em28xx_contrast_set(struct em28xx *dev, s32 val)
-{
-	u8 tmp = (u8) val;
-	return em28xx_write_regs(dev, EM28XX_R20_YGAIN, &tmp, 1);
-}
-
-static inline int em28xx_brightness_set(struct em28xx *dev, s32 val)
-{
-	u8 tmp = (u8) val;
-	return em28xx_write_regs(dev, EM28XX_R21_YOFFSET, &tmp, 1);
-}
-
-static inline int em28xx_saturation_set(struct em28xx *dev, s32 val)
-{
-	u8 tmp = (u8) val;
-	return em28xx_write_regs(dev, EM28XX_R22_UVGAIN, &tmp, 1);
-}
-
-static inline int em28xx_u_balance_set(struct em28xx *dev, s32 val)
-{
-	u8 tmp = (u8) val;
-	return em28xx_write_regs(dev, EM28XX_R23_UOFFSET, &tmp, 1);
-}
-
-static inline int em28xx_v_balance_set(struct em28xx *dev, s32 val)
-{
-	u8 tmp = (u8) val;
-	return em28xx_write_regs(dev, EM28XX_R24_VOFFSET, &tmp, 1);
-}
-
-static inline int em28xx_gamma_set(struct em28xx *dev, s32 val)
-{
-	u8 tmp = (u8) val;
-	return em28xx_write_regs(dev, EM28XX_R14_GAMMA, &tmp, 1);
-}
-
 /*FIXME: maxw should be dependent of alt mode */
 static inline unsigned int norm_maxw(struct em28xx *dev)
 {
Signature · 1 line
1.7.10.4
#2 lore raw

PATCH v2 2/4 em28xx: remove unused ac97 v4l2_ctrl_handler

In reply to Frank Schäfer
---
 drivers/media/usb/em28xx/em28xx.h |    2 --

1 Datei geändert, 2 Zeilen entfernt(-)

drivers/media/usb/em28xx/em28xx.h +0 -2
index 6a9e3e1..7dc27b5 100644
@@ -491,8 +491,6 @@ struct em28xx {
 
 	struct v4l2_device v4l2_dev;
 	struct v4l2_ctrl_handler ctrl_handler;
-	/* provides ac97 mute and volume overrides */
-	struct v4l2_ctrl_handler ac97_ctrl_handler;
 	struct em28xx_board board;
 
 	/* Webcam specific fields */
Signature · 1 line
1.7.10.4
#3 lore raw

PATCH v2 3/4 em28xx: introduce #defines for the image quality default settings

In reply to Frank Schäfer

The image quality default values will be used in at least two different places and by using #defines we make sure that they are always consistent.

---
 drivers/media/usb/em28xx/em28xx-core.c |   12 ++++++------
 drivers/media/usb/em28xx/em28xx-reg.h  |   23 +++++++++++++++++------

2 Dateien geändert, 23 Zeilen hinzugefügt(+), 12 Zeilen entfernt(-)

drivers/media/usb/em28xx/em28xx-core.c +6 -6
index 26d2499..b2dcb3d 100644
@@ -607,12 +607,12 @@ EXPORT_SYMBOL_GPL(em28xx_audio_setup);
 
 int em28xx_colorlevels_set_default(struct em28xx *dev)
 {
-	em28xx_write_reg(dev, EM28XX_R20_YGAIN, 0x10);	/* contrast */
-	em28xx_write_reg(dev, EM28XX_R21_YOFFSET, 0x00);	/* brightness */
-	em28xx_write_reg(dev, EM28XX_R22_UVGAIN, 0x10);	/* saturation */
-	em28xx_write_reg(dev, EM28XX_R23_UOFFSET, 0x00);
-	em28xx_write_reg(dev, EM28XX_R24_VOFFSET, 0x00);
-	em28xx_write_reg(dev, EM28XX_R25_SHARPNESS, 0x00);
+	em28xx_write_reg(dev, EM28XX_R20_YGAIN, CONTRAST_DEFAULT);
+	em28xx_write_reg(dev, EM28XX_R21_YOFFSET, BRIGHTNESS_DEFAULT);
+	em28xx_write_reg(dev, EM28XX_R22_UVGAIN, SATURATION_DEFAULT);
+	em28xx_write_reg(dev, EM28XX_R23_UOFFSET, BLUE_BALANCE_DEFAULT);
+	em28xx_write_reg(dev, EM28XX_R24_VOFFSET, RED_BALANCE_DEFAULT);
+	em28xx_write_reg(dev, EM28XX_R25_SHARPNESS, SHARPNESS_DEFAULT);
 
 	em28xx_write_reg(dev, EM28XX_R14_GAMMA, 0x20);
 	em28xx_write_reg(dev, EM28XX_R15_RGAIN, 0x20);
drivers/media/usb/em28xx/em28xx-reg.h +17 -6
index 0a3cb04..1e369ba 100644
@@ -120,12 +120,23 @@
 #define EM28XX_R1E_CWIDTH	0x1e
 #define EM28XX_R1F_CHEIGHT	0x1f
 
-#define EM28XX_R20_YGAIN	0x20
-#define EM28XX_R21_YOFFSET	0x21
-#define EM28XX_R22_UVGAIN	0x22
-#define EM28XX_R23_UOFFSET	0x23
-#define EM28XX_R24_VOFFSET	0x24
-#define EM28XX_R25_SHARPNESS	0x25
+#define EM28XX_R20_YGAIN	0x20 /* contrast [0:4]   */
+#define   CONTRAST_DEFAULT	0x10
+
+#define EM28XX_R21_YOFFSET	0x21 /* brightness       */	/* signed */
+#define   BRIGHTNESS_DEFAULT	0x00
+
+#define EM28XX_R22_UVGAIN	0x22 /* saturation [0:4] */
+#define   SATURATION_DEFAULT	0x10
+
+#define EM28XX_R23_UOFFSET	0x23 /* blue balance     */	/* signed */
+#define   BLUE_BALANCE_DEFAULT	0x00
+
+#define EM28XX_R24_VOFFSET	0x24 /* red balance      */	/* signed */
+#define   RED_BALANCE_DEFAULT	0x00
+
+#define EM28XX_R25_SHARPNESS	0x25 /* sharpness [0:4]  */
+#define   SHARPNESS_DEFAULT	0x00
 
 #define EM28XX_R26_COMPR	0x26
 #define EM28XX_R27_OUTFMT	0x27
Signature · 1 line
1.7.10.4
#4 lore raw

PATCH v2 4/4 em28xx: add image quality bridge controls

In reply to Frank Schäfer

Add the image quality bridge controls contrast, brightness, saturation, blue balance, red balance and sharpness.
These controls are enabled only if no subdevice provides them.

Tested with the following devices:
"Terratec Cinergy 200 USB"
"Hauppauge HVR-900"
"SilverCrest 1.3MPix webcam"
"Hauppauge WinTV USB2"
"Speedlink VAD Laplace webcam"

---
 drivers/media/usb/em28xx/em28xx-cards.c |    7 +---
 drivers/media/usb/em28xx/em28xx-video.c |   58 +++++++++++++++++++++++++++++--

2 Dateien geändert, 57 Zeilen hinzugefügt(+), 8 Zeilen entfernt(-)

drivers/media/usb/em28xx/em28xx-cards.c +1 -6
index 0a5aa62..96de831 100644
@@ -3089,7 +3089,7 @@ static int em28xx_init_dev(struct em28xx *dev, struct usb_device *udev,
 		return retval;
 	}
 
-	v4l2_ctrl_handler_init(hdl, 4);
+	v4l2_ctrl_handler_init(hdl, 8);
 	dev->v4l2_dev.ctrl_handler = hdl;
 
 	/* register i2c bus */
@@ -3158,11 +3158,6 @@ static int em28xx_init_dev(struct em28xx *dev, struct usb_device *udev,
 		msleep(3);
 	}
 
-	v4l2_ctrl_handler_setup(&dev->ctrl_handler);
-	retval = dev->ctrl_handler.error;
-	if (retval)
-		goto fail;
-
 	retval = em28xx_register_analog_devices(dev);
 	if (retval < 0) {
 		goto fail;
drivers/media/usb/em28xx/em28xx-video.c +56 -2

82 lines not on this page · raw message

Signature · 1 line
1.7.10.4