Re: [PATCH 1/3] media: soc_camera: rcar_vin: Add scaling support

2014-10-15 Thread Yoshihiro Kaneko
Hello Geert,

Thanks for your comment.
I'll update this patch.

Thanks,
Kaneko

2014-10-15 4:25 GMT+09:00 Geert Uytterhoeven ge...@linux-m68k.org:
 Hi Kaneko-san, Matsuoka-san,

 On Tue, Oct 14, 2014 at 8:26 AM, Yoshihiro Kaneko ykaneko0...@gmail.com 
 wrote:
 From: Koji Matsuoka koji.matsuoka...@renesas.com

 Thanks for our patch!

 --- a/drivers/media/platform/soc_camera/rcar_vin.c
 +++ b/drivers/media/platform/soc_camera/rcar_vin.c

 @@ -120,6 +144,326 @@ enum chip_id {
 RCAR_E1,
  };

 +struct VIN_COEFF {

 Please don't use upper case for struct names.

 +   unsigned short xs_value;
 +   unsigned long coeff_set[24];

 The actual size of long depends on the word size of the CPU.
 On 32-bit builds it is 32-bit, on 64-bit builds it is 64-bit.
 As all values in the table below are 32-bit, and the values are
 written to register using iowrite32(), please use u32 instead of
 unsigned long.

 +};

 +#define VIN_COEFF_SET_COUNT (sizeof(vin_coeff_set) / sizeof(struct 
 VIN_COEFF))

 There exists a convenience macro ARRAY_SIZE() for this.
 Please just use ARRAY_SIZE(vin_coeff_set) instead of defining
 VIN_COEFF_SET_COUNT.

 @@ -677,6 +1024,61 @@ static void rcar_vin_clock_stop(struct soc_camera_host 
 *ici)
 /* VIN does not have mclk */
  }

 +static void set_coeff(struct rcar_vin_priv *priv, unsigned long xs)

 I think xs can be unsigned short?

 +{
 +   int i;
 +   struct VIN_COEFF *p_prev_set = NULL;
 +   struct VIN_COEFF *p_set = NULL;

 If you add const to the two definitions above...

 +   /* Search the correspondence coefficient values */
 +   for (i = 0; i  VIN_COEFF_SET_COUNT; i++) {
 +   p_prev_set = p_set;
 +   p_set = (struct VIN_COEFF *) vin_coeff_set[i];

 ... the above cast is no longer needed.

 @@ -686,6 +1088,7 @@ static int rcar_vin_set_rect(struct soc_camera_device 
 *icd)
 unsigned int left_offset, top_offset;
 unsigned char dsize = 0;
 struct v4l2_rect *cam_subrect = cam-subrect;
 +   unsigned long value;

 u32, as it's written to a 32-bit register later.

 Gr{oetje,eeting}s,

 Geert

 --
 Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- 
 ge...@linux-m68k.org

 In personal conversations with technical people, I call myself a hacker. But
 when I'm talking to journalists I just say programmer or something like 
 that.
 -- Linus Torvalds
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 1/3] media: soc_camera: rcar_vin: Add scaling support

2014-10-14 Thread Yoshihiro Kaneko
From: Koji Matsuoka koji.matsuoka...@renesas.com

Signed-off-by: Koji Matsuoka koji.matsuoka...@renesas.com
Signed-off-by: Yoshihiro Kaneko ykaneko0...@gmail.com
---
 drivers/media/platform/soc_camera/rcar_vin.c | 455 ++-
 1 file changed, 446 insertions(+), 9 deletions(-)

diff --git a/drivers/media/platform/soc_camera/rcar_vin.c 
b/drivers/media/platform/soc_camera/rcar_vin.c
index bf97ed6..746f03f 100644
--- a/drivers/media/platform/soc_camera/rcar_vin.c
+++ b/drivers/media/platform/soc_camera/rcar_vin.c
@@ -64,6 +64,30 @@
 #define VNDMR_REG  0x58/* Video n Data Mode Register */
 #define VNDMR2_REG 0x5C/* Video n Data Mode Register 2 */
 #define VNUVAOF_REG0x60/* Video n UV Address Offset Register */
+#define VNC1A_REG  0x80/* Video n Coefficient Set C1A Register */
+#define VNC1B_REG  0x84/* Video n Coefficient Set C1B Register */
+#define VNC1C_REG  0x88/* Video n Coefficient Set C1C Register */
+#define VNC2A_REG  0x90/* Video n Coefficient Set C2A Register */
+#define VNC2B_REG  0x94/* Video n Coefficient Set C2B Register */
+#define VNC2C_REG  0x98/* Video n Coefficient Set C2C Register */
+#define VNC3A_REG  0xA0/* Video n Coefficient Set C3A Register */
+#define VNC3B_REG  0xA4/* Video n Coefficient Set C3B Register */
+#define VNC3C_REG  0xA8/* Video n Coefficient Set C3C Register */
+#define VNC4A_REG  0xB0/* Video n Coefficient Set C4A Register */
+#define VNC4B_REG  0xB4/* Video n Coefficient Set C4B Register */
+#define VNC4C_REG  0xB8/* Video n Coefficient Set C4C Register */
+#define VNC5A_REG  0xC0/* Video n Coefficient Set C5A Register */
+#define VNC5B_REG  0xC4/* Video n Coefficient Set C5B Register */
+#define VNC5C_REG  0xC8/* Video n Coefficient Set C5C Register */
+#define VNC6A_REG  0xD0/* Video n Coefficient Set C6A Register */
+#define VNC6B_REG  0xD4/* Video n Coefficient Set C6B Register */
+#define VNC6C_REG  0xD8/* Video n Coefficient Set C6C Register */
+#define VNC7A_REG  0xE0/* Video n Coefficient Set C7A Register */
+#define VNC7B_REG  0xE4/* Video n Coefficient Set C7B Register */
+#define VNC7C_REG  0xE8/* Video n Coefficient Set C7C Register */
+#define VNC8A_REG  0xF0/* Video n Coefficient Set C8A Register */
+#define VNC8B_REG  0xF4/* Video n Coefficient Set C8B Register */
+#define VNC8C_REG  0xF8/* Video n Coefficient Set C8C Register */
 
 /* Register bit fields for R-Car VIN */
 /* Video n Main Control Register bits */
@@ -120,6 +144,326 @@ enum chip_id {
RCAR_E1,
 };
 
+struct VIN_COEFF {
+   unsigned short xs_value;
+   unsigned long coeff_set[24];
+};
+
+static const struct VIN_COEFF vin_coeff_set[] = {
+   { 0x, {
+   0x, 0x, 0x,
+   0x, 0x, 0x,
+   0x, 0x, 0x,
+   0x, 0x, 0x,
+   0x, 0x, 0x,
+   0x, 0x, 0x,
+   0x, 0x, 0x,
+   0x, 0x, 0x },
+   },
+   { 0x1000, {
+   0x000fa400, 0x000fa400, 0x09625902,
+   0x03f8, 0x0403, 0x3de0d9f0,
+   0x001fffed, 0x0804, 0x3cc1f9c3,
+   0x001003de, 0x0c01, 0x3cb34d7f,
+   0x002003d2, 0x0c00, 0x3d24a92d,
+   0x00200bca, 0x0bff, 0x3df600d2,
+   0x002013cc, 0x07ff, 0x3ed70c7e,
+   0x00100fde, 0x, 0x3f87c036 },
+   },
+   { 0x1200, {
+   0x0021, 0x0021, 0x02a0a9c8,
+   0x002003e7, 0x001a, 0x000185bc,
+   0x002007dc, 0x03ff, 0x3e52859c,
+   0x00200bd4, 0x0002, 0x3d53996b,
+   0x00100fd0, 0x0403, 0x3d04ad2d,
+   0x0bd5, 0x0403, 0x3d35ace7,
+   0x3ff003e4, 0x0801, 0x3dc674a1,
+   0x3fffe800, 0x0800, 0x3e76f461 },
+   },
+   { 0x1400, {
+   0x00100be3, 0x00100be3, 0x04d1359a,
+   0x0fdb, 0x002003ed, 0x0211fd93,
+   0x0fd6, 0x002003f4, 

Re: [PATCH 1/3] media: soc_camera: rcar_vin: Add scaling support

2014-10-14 Thread Geert Uytterhoeven
Hi Kaneko-san, Matsuoka-san,

On Tue, Oct 14, 2014 at 8:26 AM, Yoshihiro Kaneko ykaneko0...@gmail.com wrote:
 From: Koji Matsuoka koji.matsuoka...@renesas.com

Thanks for our patch!

 --- a/drivers/media/platform/soc_camera/rcar_vin.c
 +++ b/drivers/media/platform/soc_camera/rcar_vin.c

 @@ -120,6 +144,326 @@ enum chip_id {
 RCAR_E1,
  };

 +struct VIN_COEFF {

Please don't use upper case for struct names.

 +   unsigned short xs_value;
 +   unsigned long coeff_set[24];

The actual size of long depends on the word size of the CPU.
On 32-bit builds it is 32-bit, on 64-bit builds it is 64-bit.
As all values in the table below are 32-bit, and the values are
written to register using iowrite32(), please use u32 instead of
unsigned long.

 +};

 +#define VIN_COEFF_SET_COUNT (sizeof(vin_coeff_set) / sizeof(struct 
 VIN_COEFF))

There exists a convenience macro ARRAY_SIZE() for this.
Please just use ARRAY_SIZE(vin_coeff_set) instead of defining
VIN_COEFF_SET_COUNT.

 @@ -677,6 +1024,61 @@ static void rcar_vin_clock_stop(struct soc_camera_host 
 *ici)
 /* VIN does not have mclk */
  }

 +static void set_coeff(struct rcar_vin_priv *priv, unsigned long xs)

I think xs can be unsigned short?

 +{
 +   int i;
 +   struct VIN_COEFF *p_prev_set = NULL;
 +   struct VIN_COEFF *p_set = NULL;

If you add const to the two definitions above...

 +   /* Search the correspondence coefficient values */
 +   for (i = 0; i  VIN_COEFF_SET_COUNT; i++) {
 +   p_prev_set = p_set;
 +   p_set = (struct VIN_COEFF *) vin_coeff_set[i];

... the above cast is no longer needed.

 @@ -686,6 +1088,7 @@ static int rcar_vin_set_rect(struct soc_camera_device 
 *icd)
 unsigned int left_offset, top_offset;
 unsigned char dsize = 0;
 struct v4l2_rect *cam_subrect = cam-subrect;
 +   unsigned long value;

u32, as it's written to a 32-bit register later.

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- ge...@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say programmer or something like that.
-- Linus Torvalds
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html