Re: Support for RGB/YUV 10, 12 BPC(bits per color/component) image data formats in kernel
Hi Sakari, On Sat, Jun 3, 2017 at 1:48 PM, Sakari Ailus wrote: > Hi Ajay, > > On Fri, Jun 02, 2017 at 06:38:53PM +0530, Ajay kumar wrote: >> Hi all, >> >> I have tried searching for RGB/YUV 10, 12 BPC formats in videodev2.h, >> media-bus-format.h and drm_fourcc.h >> I could only find RGB 10BPC support in drm_fourcc.h. >> I guess not much support is present for formats with (BPC > 8) in the kernel. > > What's "BPC"? Most YUV and RGB formats have only 8 bits per sample. More > format definitions may be added if there's a driver that makes use of them. BPC : Bits Per Color/Component In my project, we have an image capture device which can capture 10 or 12 bits for each of R, G, B colors, i.e: R[0:9] G[0:9] B[0:9] and R[0:11] G[0:11] B[0:11] I want to define macros for the above formats in videodev2.h. But, I am not getting the logic behind the naming convention used to define v4l2_fourcc macros. ex: V4L2_PIX_FMT_ARGB32 v4l2_fourcc('A', 'R', '2', '4'); How did they choose the characters 'A', 'R', '2', '4' in the above case? I want to know the logic/naming convention behind that, so that I can create new v4l2_fourcc defines for 10, 12 BPC formats and use in my driver. Thanks, Ajay Kumar >> >> Are there any plans to add fourcc defines for such formats? >> Also, I wanted to how to define fourcc code for those formats? > > -- > Regards, > > Sakari Ailus > e-mail: sakari.ai...@iki.fi XMPP: sai...@retiisi.org.uk
Support for RGB/YUV 10, 12 BPC(bits per color/component) image data formats in kernel
Hi all, I have tried searching for RGB/YUV 10, 12 BPC formats in videodev2.h, media-bus-format.h and drm_fourcc.h I could only find RGB 10BPC support in drm_fourcc.h. I guess not much support is present for formats with (BPC > 8) in the kernel. Are there any plans to add fourcc defines for such formats? Also, I wanted to how to define fourcc code for those formats? Thanks, Ajay Kumar
Re: v4l2: Adding support for multiple MIPI CSI-2 virtual channels
Hi Everyone, On Fri, Feb 17, 2017 at 7:27 PM, Thomas Axelsson wrote: > Hi, > > I have a v4l2_subdev that provides multiple MIPI CSI-2 Virtual Channels. I > want to configure each virtual channel individually (e.g. set_fmt), but the > v4l2 interface does not seem to have a clear way to access configuration on a > virtual channel level, but only the v4l2_subdev as a whole. Using one > v4l2_subdev for multiple virtual channels by extending the "reg" tag to be an > array looks like the correct way to do it, based on the mipi-dsi-bus.txt > document and current device tree endpoint structure. > > However, I cannot figure out how to extend e.g. set_fmt/get_fmt subdev ioctls > to specify which virtual channel the call applies to. Does anyone have any > advice on how to handle this case? This would be helpful for my project as well since even I need to support multiple streams using Virtual Channels. Can anyone point out to some V4L2 driver, if this kind of support is already implemented? Thanks. > > Previous thread: "Device Tree formatting for multiple virtual channels in > ti-vpe/cal driver?" > > > Best Regards, > Thomas Axelsson > > PS. First e-mail seems to have gotten caught in the spam filter. I apologize > if this is a duplicate.
Re: [PATCH v2 1/1] media: video: s5p-g2d: Add support for FIMG2D v41 H/W logic
Hi Mr.Sakari On Sun, Mar 18, 2012 at 12:27 AM, Sakari Ailus wrote: > Hi Ajay, > > Thanks for the patch. I have a few comments below. > > On Sat, Mar 17, 2012 at 04:52:14PM +0530, Ajay Kumar wrote: >> Modify the G2D driver(which initially supported only FIMG2D v3 style H/W) >> to support FIMG2D v41 style hardware present on Exynos4x12 and Exynos52x0 >> SOC. >> >> -- Set the SRC and DST type to 'memory' instead of using reset values. >> -- FIMG2D v41 H/W uses different logic for stretching(scaling). >> -- Use CACHECTL_REG only with FIMG2D v3. >> >> Signed-off-by: Ajay Kumar >> --- >> drivers/media/video/s5p-g2d/g2d-hw.c | 39 >> --- >> drivers/media/video/s5p-g2d/g2d-regs.h | 6 + >> drivers/media/video/s5p-g2d/g2d.c | 23 +- >> drivers/media/video/s5p-g2d/g2d.h | 9 ++- >> 4 files changed, 70 insertions(+), 7 deletions(-) >> >> diff --git a/drivers/media/video/s5p-g2d/g2d-hw.c >> b/drivers/media/video/s5p-g2d/g2d-hw.c >> index 5b86cbe..f8225b8 100644 >> --- a/drivers/media/video/s5p-g2d/g2d-hw.c >> +++ b/drivers/media/video/s5p-g2d/g2d-hw.c >> @@ -28,6 +28,8 @@ void g2d_set_src_size(struct g2d_dev *d, struct g2d_frame >> *f) >> { >> u32 n; >> >> + w(0, SRC_SELECT_REG); >> + >> w(f->stride & 0x, SRC_STRIDE_REG); >> >> n = f->o_height & 0xFFF; >> @@ -52,6 +54,8 @@ void g2d_set_dst_size(struct g2d_dev *d, struct g2d_frame >> *f) >> { >> u32 n; >> >> + w(0, DST_SELECT_REG); >> + >> w(f->stride & 0x, DST_STRIDE_REG); >> >> n = f->o_height & 0xFFF; >> @@ -82,10 +86,36 @@ void g2d_set_flip(struct g2d_dev *d, u32 r) >> w(r, SRC_MSK_DIRECT_REG); >> } >> >> -u32 g2d_cmd_stretch(u32 e) >> +/** >> + * g2d_calc_scale_factor - convert scale factor to fixed pint 16 > > Point, perhaps? Ok. Typo. >> + * @n: numerator >> + * @d: denominator >> + */ >> +static unsigned long g2d_calc_scale_factor(int n, int d) >> +{ >> + return (n << 16) / d; >> +} >> + >> +void g2d_set_v41_stretch(struct g2d_dev *d, struct g2d_frame *src, >> + struct g2d_frame *dst) >> { >> - e &= 1; >> - return e << 4; >> + int src_w, src_h, dst_w, dst_h; > > Is int intentional --- width and height usually can't be negative. I will use 'unsigned int'. >> + u32 wcfg, hcfg; >> + >> + w(DEFAULT_SCALE_MODE, SRC_SCALE_CTRL_REG); >> + >> + src_w = src->c_width; >> + src_h = src->c_height; >> + >> + dst_w = dst->c_width; >> + dst_h = dst->c_height; >> + >> + /* inversed scaling factor: src is numerator */ >> + wcfg = g2d_calc_scale_factor(src_w, dst_w); >> + hcfg = g2d_calc_scale_factor(src_h, dst_h); > > I think this would be more simple without that many temporary variables and > an extra function. You are right. I will Change it. >> + w(wcfg, SRC_XSCALE_REG); >> + w(hcfg, SRC_YSCALE_REG); >> } >> >> void g2d_set_cmd(struct g2d_dev *d, u32 c) >> @@ -96,7 +126,8 @@ void g2d_set_cmd(struct g2d_dev *d, u32 c) >> void g2d_start(struct g2d_dev *d) >> { >> /* Clear cache */ >> - w(0x7, CACHECTL_REG); >> + if (d->device_type == TYPE_G2D_3X) >> + w(0x7, CACHECTL_REG); >> /* Enable interrupt */ >> w(1, INTEN_REG); >> /* Start G2D engine */ > > Kind regards, > > -- > Sakari Ailus > e-mail: sakari.ai...@iki.fi jabber/XMPP/Gmail: sai...@retiisi.org.uk > -- > 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 Thanks for your review and comments. I will resubmit the patch with changes. Regards, Ajay -- 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 v2 1/1] media: video: s5p-g2d: Add support for FIMG2D v41 H/W logic
Modify the G2D driver(which initially supported only FIMG2D v3 style H/W) to support FIMG2D v41 style hardware present on Exynos4x12 and Exynos52x0 SOC. -- Set the SRC and DST type to 'memory' instead of using reset values. -- FIMG2D v41 H/W uses different logic for stretching(scaling). -- Use CACHECTL_REG only with FIMG2D v3. Signed-off-by: Ajay Kumar --- drivers/media/video/s5p-g2d/g2d-hw.c | 39 --- drivers/media/video/s5p-g2d/g2d-regs.h |6 + drivers/media/video/s5p-g2d/g2d.c | 23 +- drivers/media/video/s5p-g2d/g2d.h |9 ++- 4 files changed, 70 insertions(+), 7 deletions(-) diff --git a/drivers/media/video/s5p-g2d/g2d-hw.c b/drivers/media/video/s5p-g2d/g2d-hw.c index 5b86cbe..f8225b8 100644 --- a/drivers/media/video/s5p-g2d/g2d-hw.c +++ b/drivers/media/video/s5p-g2d/g2d-hw.c @@ -28,6 +28,8 @@ void g2d_set_src_size(struct g2d_dev *d, struct g2d_frame *f) { u32 n; + w(0, SRC_SELECT_REG); + w(f->stride & 0x, SRC_STRIDE_REG); n = f->o_height & 0xFFF; @@ -52,6 +54,8 @@ void g2d_set_dst_size(struct g2d_dev *d, struct g2d_frame *f) { u32 n; + w(0, DST_SELECT_REG); + w(f->stride & 0x, DST_STRIDE_REG); n = f->o_height & 0xFFF; @@ -82,10 +86,36 @@ void g2d_set_flip(struct g2d_dev *d, u32 r) w(r, SRC_MSK_DIRECT_REG); } -u32 g2d_cmd_stretch(u32 e) +/** + * g2d_calc_scale_factor - convert scale factor to fixed pint 16 + * @n: numerator + * @d: denominator + */ +static unsigned long g2d_calc_scale_factor(int n, int d) +{ + return (n << 16) / d; +} + +void g2d_set_v41_stretch(struct g2d_dev *d, struct g2d_frame *src, + struct g2d_frame *dst) { - e &= 1; - return e << 4; + int src_w, src_h, dst_w, dst_h; + u32 wcfg, hcfg; + + w(DEFAULT_SCALE_MODE, SRC_SCALE_CTRL_REG); + + src_w = src->c_width; + src_h = src->c_height; + + dst_w = dst->c_width; + dst_h = dst->c_height; + + /* inversed scaling factor: src is numerator */ + wcfg = g2d_calc_scale_factor(src_w, dst_w); + hcfg = g2d_calc_scale_factor(src_h, dst_h); + + w(wcfg, SRC_XSCALE_REG); + w(hcfg, SRC_YSCALE_REG); } void g2d_set_cmd(struct g2d_dev *d, u32 c) @@ -96,7 +126,8 @@ void g2d_set_cmd(struct g2d_dev *d, u32 c) void g2d_start(struct g2d_dev *d) { /* Clear cache */ - w(0x7, CACHECTL_REG); + if (d->device_type == TYPE_G2D_3X) + w(0x7, CACHECTL_REG); /* Enable interrupt */ w(1, INTEN_REG); /* Start G2D engine */ diff --git a/drivers/media/video/s5p-g2d/g2d-regs.h b/drivers/media/video/s5p-g2d/g2d-regs.h index 02e1cf5..14c681f 100644 --- a/drivers/media/video/s5p-g2d/g2d-regs.h +++ b/drivers/media/video/s5p-g2d/g2d-regs.h @@ -35,6 +35,9 @@ #define SRC_COLOR_MODE_REG 0x030C /* Src Image Color Mode reg */ #define SRC_LEFT_TOP_REG 0x0310 /* Src Left Top Coordinate reg */ #define SRC_RIGHT_BOTTOM_REG 0x0314 /* Src Right Bottom Coordinate reg */ +#define SRC_SCALE_CTRL_REG 0x0328 /* Src Scaling type select */ +#define SRC_XSCALE_REG 0x032c /* Src X Scaling ratio */ +#define SRC_YSCALE_REG 0x0330 /* Src Y Scaling ratio */ /* Parameter Setting Registers (Dest) */ #define DST_SELECT_REG 0x0400 /* Dest Image Selection reg */ @@ -112,4 +115,7 @@ #define DEFAULT_WIDTH 100 #define DEFAULT_HEIGHT 100 +#define DEFAULT_SCALE_MODE (2 << 0) +/* Command mode register values */ +#define CMD_V3_ENABLE_STRETCH (1 << 4) diff --git a/drivers/media/video/s5p-g2d/g2d.c b/drivers/media/video/s5p-g2d/g2d.c index 789de74..8924f7e 100644 --- a/drivers/media/video/s5p-g2d/g2d.c +++ b/drivers/media/video/s5p-g2d/g2d.c @@ -582,8 +582,13 @@ static void device_run(void *prv) g2d_set_flip(dev, ctx->flip); if (ctx->in.c_width != ctx->out.c_width || - ctx->in.c_height != ctx->out.c_height) - cmd |= g2d_cmd_stretch(1); + ctx->in.c_height != ctx->out.c_height) { + if (dev->device_type == TYPE_G2D_3X) + cmd |= CMD_V3_ENABLE_STRETCH; + else + g2d_set_v41_stretch(dev, &ctx->in, &ctx->out); + } + g2d_set_cmd(dev, cmd); g2d_start(dev); @@ -783,6 +788,8 @@ static int g2d_probe(struct platform_device *pdev) def_frame.stride = (def_frame.width * def_frame.fmt->depth) >> 3; + dev->device_type = platform_get_device_id(pdev)->driver_data; + return 0; unreg_video_dev: @@ -832,9 +839,21 @@ static int g2d_remove(struct platform_device *pdev) return 0; } +static struct platform_device_id g2d_driver_ids[] = { + { +
[PATCH v2 0/1] media: video: s5p-g2d: Add support for FIMG2D v41 H/W logic
The patches are created against "media-for-next" branch of kmpark's tree at: git://git.infradead.org/users/kmpark/linux-2.6-samsung The existing G2D driver supports only FIMG2D v3 style H/W. This Patch modifies the existing G2D driver to support FIMG2D v41 style H/W. FIMG2D v41 is present in Exynos4x12 and Exynos52x0 boards. Patchset 1: http://patchwork.linuxtv.org/patch/10330/ Changes from Patchset1: -- Define 2 device_type ids(TYPE_G2D_3X and TYPE_G2D_41X) instead of 3 -- Replace scale_factor_to_fixed16 function by g2d_calc_scale_factor -- Rename g2d_cmd_stretch function as g2d_set_v41_stretch -- Define and use CMD_V3_ENABLE_STRETCH instead of using (1 << 4) Hi Mr.Kyungmin Park, I have defined only 2 type ids as per spec - TYPE_G2D_3X and TYPE_G2D_41X. Also, this patch works with dummy clock scheme for sclk_fimg2d on Exynos5. Hi Mr.Kamil, I have made changes as per your comments. Patch is tested for stretching, ROP and flip features on Exynos5. To Kamil: media: video: s5p-g2d: Add support for FIMG2D v41 H/W logic drivers/media/video/s5p-g2d/g2d-hw.c | 39 --- drivers/media/video/s5p-g2d/g2d-regs.h |6 + drivers/media/video/s5p-g2d/g2d.c | 23 +- drivers/media/video/s5p-g2d/g2d.h |9 ++- 4 files changed, 70 insertions(+), 7 deletions(-) -- 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/1] media: video: s5p-g2d: Add support for FIMG2D v4 H/W logic
Modify the G2D driver(which initially supported only FIMG2D v3 style H/W) to support FIMG2D v4 style hardware present on Exynos4x12 and Exynos52x0 SOC. -- Set the SRC and DST type to 'memory' instead of using reset values. -- FIMG2D v4 H/W uses different logic for stretching(scaling). -- Use CACHECTL_REG only with FIMG2D v3. -- No Source clock for G2D on EXYNOS5. Only gating clock to be used. Signed-off-by: Ajay Kumar --- drivers/media/video/s5p-g2d/g2d-hw.c | 54 ++-- drivers/media/video/s5p-g2d/g2d-regs.h |4 ++ drivers/media/video/s5p-g2d/g2d.c | 61 +++- drivers/media/video/s5p-g2d/g2d.h | 10 +- 4 files changed, 107 insertions(+), 22 deletions(-) diff --git a/drivers/media/video/s5p-g2d/g2d-hw.c b/drivers/media/video/s5p-g2d/g2d-hw.c index 5b86cbe..7631756 100644 --- a/drivers/media/video/s5p-g2d/g2d-hw.c +++ b/drivers/media/video/s5p-g2d/g2d-hw.c @@ -28,6 +28,8 @@ void g2d_set_src_size(struct g2d_dev *d, struct g2d_frame *f) { u32 n; + w(0, SRC_SELECT_REG); + w(f->stride & 0x, SRC_STRIDE_REG); n = f->o_height & 0xFFF; @@ -52,6 +54,8 @@ void g2d_set_dst_size(struct g2d_dev *d, struct g2d_frame *f) { u32 n; + w(0, DST_SELECT_REG); + w(f->stride & 0x, DST_STRIDE_REG); n = f->o_height & 0xFFF; @@ -82,10 +86,51 @@ void g2d_set_flip(struct g2d_dev *d, u32 r) w(r, SRC_MSK_DIRECT_REG); } -u32 g2d_cmd_stretch(u32 e) +/** + * scale_factor_to_fixed16 - convert scale factor to fixed pint 16 + * @n: numerator + * @d: denominator + */ +static unsigned long scale_factor_to_fixed16(int n, int d) +{ + int i; + u32 fixed16; + + fixed16 = (n/d) << 16; + n %= d; + + for (i = 0; i < 16; i++) { + if (!n) + break; + n <<= 1; + if (n/d) + fixed16 |= 1 << (15-i); + n %= d; + } + + return fixed16; +} + +void g2d_cmd_stretch(struct g2d_dev *d, struct g2d_frame *src, + struct g2d_frame *dst) { - e &= 1; - return e << 4; + int src_w, src_h, dst_w, dst_h; + u32 wcfg, hcfg; + + w(DEFAULT_SCALE_MODE, SRC_SCALE_CTRL_REG); + + src_w = src->c_width; + src_h = src->c_height; + + dst_w = dst->c_width; + dst_h = dst->c_height; + + /* inversed scaling factor: src is numerator */ + wcfg = scale_factor_to_fixed16(src_w, dst_w); + hcfg = scale_factor_to_fixed16(src_h, dst_h); + + w(wcfg, SRC_XSCALE_REG); + w(hcfg, SRC_YSCALE_REG); } void g2d_set_cmd(struct g2d_dev *d, u32 c) @@ -96,7 +141,8 @@ void g2d_set_cmd(struct g2d_dev *d, u32 c) void g2d_start(struct g2d_dev *d) { /* Clear cache */ - w(0x7, CACHECTL_REG); + if (d->device_type == TYPE_G2D_3X) + w(0x7, CACHECTL_REG); /* Enable interrupt */ w(1, INTEN_REG); /* Start G2D engine */ diff --git a/drivers/media/video/s5p-g2d/g2d-regs.h b/drivers/media/video/s5p-g2d/g2d-regs.h index 02e1cf5..619eb9c 100644 --- a/drivers/media/video/s5p-g2d/g2d-regs.h +++ b/drivers/media/video/s5p-g2d/g2d-regs.h @@ -35,6 +35,9 @@ #define SRC_COLOR_MODE_REG 0x030C /* Src Image Color Mode reg */ #define SRC_LEFT_TOP_REG 0x0310 /* Src Left Top Coordinate reg */ #define SRC_RIGHT_BOTTOM_REG 0x0314 /* Src Right Bottom Coordinate reg */ +#define SRC_SCALE_CTRL_REG 0x0328 /* Src Scaling type select */ +#define SRC_XSCALE_REG 0x032c /* Src X Scaling ratio */ +#define SRC_YSCALE_REG 0x0330 /* Src Y Scaling ratio */ /* Parameter Setting Registers (Dest) */ #define DST_SELECT_REG 0x0400 /* Dest Image Selection reg */ @@ -112,4 +115,5 @@ #define DEFAULT_WIDTH 100 #define DEFAULT_HEIGHT 100 +#define DEFAULT_SCALE_MODE (2 << 0) diff --git a/drivers/media/video/s5p-g2d/g2d.c b/drivers/media/video/s5p-g2d/g2d.c index 789de74..4bdc227 100644 --- a/drivers/media/video/s5p-g2d/g2d.c +++ b/drivers/media/video/s5p-g2d/g2d.c @@ -582,8 +582,13 @@ static void device_run(void *prv) g2d_set_flip(dev, ctx->flip); if (ctx->in.c_width != ctx->out.c_width || - ctx->in.c_height != ctx->out.c_height) - cmd |= g2d_cmd_stretch(1); + ctx->in.c_height != ctx->out.c_height) { + if (dev->device_type == TYPE_G2D_3X) + cmd |= (1 << 4); + else + g2d_cmd_stretch(dev, &ctx->in, &ctx->out); + } + g2d_set_cmd(dev, cmd); g2d_start(dev); @@ -705,17 +710,20 @@ static int g2d_probe(struct platform_device *pdev) goto rel_res_regs;
[PATCH 0/1] media: video: s5p-g2d: Add Support for FIMG2D v4 style H/W
The existing G2D driver supports only FIMG2D v3 style H/W. This Patch modifies the existing G2D driver to support FIMG2D v4 style H/W. FIMG2D v4 is present in Exynos4x12 and Exynos52x0 boards. Differences between FIMG2Dv3 and FIMG2Dv4: --Default register values for SRC and DST type is different in v4. --The stretching(Scaling) logic is different in v4. --CACHECTRL_REG Register is not present in v4. Even though Exynos4x12 and Exynos52x0 have same FIMG2D v4 H/W, the source clock for fimg2d is present only in Exynos4x12. Exynos52x0 uses only gating clock. So, 3 type-id are defined inside the driver to distinguish between Exynos4210, Exynos4x12 and Exynos52x0. Ajay Kumar (1): [PATCH 1/1]media: video: s5p-g2d: Add support for FIMG2D v4 H/W logic drivers/media/video/s5p-g2d/g2d-hw.c | 54 ++-- drivers/media/video/s5p-g2d/g2d-regs.h |4 ++ drivers/media/video/s5p-g2d/g2d.c | 61 +++- drivers/media/video/s5p-g2d/g2d.h | 10 +- 4 files changed, 107 insertions(+), 22 deletions(-) -- 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