Skip to content

Commit

Permalink
[media] bdisp: 2D blitter driver using v4l2 mem2mem framework
Browse files Browse the repository at this point in the history
This v4l2 mem2mem driver is a 2D blitter for STMicroelectronics SoC.
It uses the v4l2 mem2mem framework.

The following features are supported and tested:
- Color format conversion (RGB32, RGB24, RGB16, NV12, YUV420P)
- Copy
- Scale
- Flip
- Deinterlace
- Wide (4K) picture support
- Crop

Signed-off-by: Fabien Dessenne <fabien.dessenne@st.com>
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
[hans.verkuil@cisco.com: added missing slab.h include to bdisp-v4l2.c]

Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
  • Loading branch information
Fabien Dessenne authored and mchehab committed Jun 9, 2015
1 parent 5a54cd2 commit 28ffeeb
Show file tree
Hide file tree
Showing 9 changed files with 2,979 additions and 0 deletions.
10 changes: 10 additions & 0 deletions drivers/media/platform/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,16 @@ config VIDEO_SAMSUNG_EXYNOS_GSC
help
This is a v4l2 driver for Samsung EXYNOS5 SoC G-Scaler.

config VIDEO_STI_BDISP
tristate "STMicroelectronics BDISP 2D blitter driver"
depends on VIDEO_DEV && VIDEO_V4L2
depends on ARCH_STI || COMPILE_TEST
depends on HAS_DMA
select VIDEOBUF2_DMA_CONTIG
select V4L2_MEM2MEM_DEV
help
This v4l2 mem2mem driver is a 2D blitter for STMicroelectronics SoC.

config VIDEO_SH_VEU
tristate "SuperH VEU mem2mem video processing driver"
depends on VIDEO_DEV && VIDEO_V4L2 && HAS_DMA
Expand Down
2 changes: 2 additions & 0 deletions drivers/media/platform/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ obj-$(CONFIG_VIDEO_SAMSUNG_S5P_TV) += s5p-tv/
obj-$(CONFIG_VIDEO_SAMSUNG_S5P_G2D) += s5p-g2d/
obj-$(CONFIG_VIDEO_SAMSUNG_EXYNOS_GSC) += exynos-gsc/

obj-$(CONFIG_VIDEO_STI_BDISP) += sti/bdisp/

obj-$(CONFIG_BLACKFIN) += blackfin/

obj-$(CONFIG_ARCH_DAVINCI) += davinci/
Expand Down
9 changes: 9 additions & 0 deletions drivers/media/platform/sti/bdisp/Kconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
config VIDEO_STI_BDISP
tristate "STMicroelectronics BDISP 2D blitter driver"
depends on VIDEO_DEV && VIDEO_V4L2
select VIDEOBUF2_DMA_CONTIG
select V4L2_MEM2MEM_DEV
help
This v4l2 mem2mem driver is a 2D blitter for STMicroelectronics SoC.
To compile this driver as a module, choose M here: the module will
be called bdisp.ko.
3 changes: 3 additions & 0 deletions drivers/media/platform/sti/bdisp/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
obj-$(CONFIG_VIDEO_STI_BDISP) := bdisp.o

bdisp-objs := bdisp-v4l2.o bdisp-hw.o
346 changes: 346 additions & 0 deletions drivers/media/platform/sti/bdisp/bdisp-filter.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,346 @@
/*
* Copyright (C) STMicroelectronics SA 2014
* Authors: Fabien Dessenne <fabien.dessenne@st.com> for STMicroelectronics.
* License terms: GNU General Public License (GPL), version 2
*/

#define BDISP_HF_NB 64
#define BDISP_VF_NB 40

/**
* struct bdisp_filter_h_spec - Horizontal filter specification
*
* @min: min scale factor for this filter (6.10 fixed point)
* @max: max scale factor for this filter (6.10 fixed point)
* coef: filter coefficients
*/
struct bdisp_filter_h_spec {
const u16 min;
const u16 max;
const u8 coef[BDISP_HF_NB];
};

static const struct bdisp_filter_h_spec bdisp_h_spec[] = {
{
.min = 0,
.max = 921,
.coef = {
0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00,
0x00, 0x00, 0xff, 0x07, 0x3d, 0xfc, 0x01, 0x00,
0x00, 0x01, 0xfd, 0x11, 0x36, 0xf9, 0x02, 0x00,
0x00, 0x01, 0xfb, 0x1b, 0x2e, 0xf9, 0x02, 0x00,
0x00, 0x01, 0xf9, 0x26, 0x26, 0xf9, 0x01, 0x00,
0x00, 0x02, 0xf9, 0x30, 0x19, 0xfb, 0x01, 0x00,
0x00, 0x02, 0xf9, 0x39, 0x0e, 0xfd, 0x01, 0x00,
0x00, 0x01, 0xfc, 0x3e, 0x06, 0xff, 0x00, 0x00
}
},
{
.min = 921,
.max = 1024,
.coef = {
0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00,
0xff, 0x03, 0xfd, 0x08, 0x3e, 0xf9, 0x04, 0xfe,
0xfd, 0x06, 0xf8, 0x13, 0x3b, 0xf4, 0x07, 0xfc,
0xfb, 0x08, 0xf5, 0x1f, 0x34, 0xf1, 0x09, 0xfb,
0xfb, 0x09, 0xf2, 0x2b, 0x2a, 0xf1, 0x09, 0xfb,
0xfb, 0x09, 0xf2, 0x35, 0x1e, 0xf4, 0x08, 0xfb,
0xfc, 0x07, 0xf5, 0x3c, 0x12, 0xf7, 0x06, 0xfd,
0xfe, 0x04, 0xfa, 0x3f, 0x07, 0xfc, 0x03, 0xff
}
},
{
.min = 1024,
.max = 1126,
.coef = {
0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00,
0xff, 0x03, 0xfd, 0x08, 0x3e, 0xf9, 0x04, 0xfe,
0xfd, 0x06, 0xf8, 0x13, 0x3b, 0xf4, 0x07, 0xfc,
0xfb, 0x08, 0xf5, 0x1f, 0x34, 0xf1, 0x09, 0xfb,
0xfb, 0x09, 0xf2, 0x2b, 0x2a, 0xf1, 0x09, 0xfb,
0xfb, 0x09, 0xf2, 0x35, 0x1e, 0xf4, 0x08, 0xfb,
0xfc, 0x07, 0xf5, 0x3c, 0x12, 0xf7, 0x06, 0xfd,
0xfe, 0x04, 0xfa, 0x3f, 0x07, 0xfc, 0x03, 0xff
}
},
{
.min = 1126,
.max = 1228,
.coef = {
0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00,
0xff, 0x03, 0xfd, 0x08, 0x3e, 0xf9, 0x04, 0xfe,
0xfd, 0x06, 0xf8, 0x13, 0x3b, 0xf4, 0x07, 0xfc,
0xfb, 0x08, 0xf5, 0x1f, 0x34, 0xf1, 0x09, 0xfb,
0xfb, 0x09, 0xf2, 0x2b, 0x2a, 0xf1, 0x09, 0xfb,
0xfb, 0x09, 0xf2, 0x35, 0x1e, 0xf4, 0x08, 0xfb,
0xfc, 0x07, 0xf5, 0x3c, 0x12, 0xf7, 0x06, 0xfd,
0xfe, 0x04, 0xfa, 0x3f, 0x07, 0xfc, 0x03, 0xff
}
},
{
.min = 1228,
.max = 1331,
.coef = {
0xfd, 0x04, 0xfc, 0x05, 0x39, 0x05, 0xfc, 0x04,
0xfc, 0x06, 0xf9, 0x0c, 0x39, 0xfe, 0x00, 0x02,
0xfb, 0x08, 0xf6, 0x17, 0x35, 0xf9, 0x02, 0x00,
0xfc, 0x08, 0xf4, 0x20, 0x30, 0xf4, 0x05, 0xff,
0xfd, 0x07, 0xf4, 0x29, 0x28, 0xf3, 0x07, 0xfd,
0xff, 0x05, 0xf5, 0x31, 0x1f, 0xf3, 0x08, 0xfc,
0x00, 0x02, 0xf9, 0x38, 0x14, 0xf6, 0x08, 0xfb,
0x02, 0x00, 0xff, 0x3a, 0x0b, 0xf8, 0x06, 0xfc
}
},
{
.min = 1331,
.max = 1433,
.coef = {
0xfc, 0x06, 0xf9, 0x09, 0x34, 0x09, 0xf9, 0x06,
0xfd, 0x07, 0xf7, 0x10, 0x32, 0x02, 0xfc, 0x05,
0xfe, 0x07, 0xf6, 0x17, 0x2f, 0xfc, 0xff, 0x04,
0xff, 0x06, 0xf5, 0x20, 0x2a, 0xf9, 0x01, 0x02,
0x00, 0x04, 0xf6, 0x27, 0x25, 0xf6, 0x04, 0x00,
0x02, 0x01, 0xf9, 0x2d, 0x1d, 0xf5, 0x06, 0xff,
0x04, 0xff, 0xfd, 0x31, 0x15, 0xf5, 0x07, 0xfe,
0x05, 0xfc, 0x02, 0x35, 0x0d, 0xf7, 0x07, 0xfd
}
},
{
.min = 1433,
.max = 1536,
.coef = {
0xfe, 0x06, 0xf8, 0x0b, 0x30, 0x0b, 0xf8, 0x06,
0xff, 0x06, 0xf7, 0x12, 0x2d, 0x05, 0xfa, 0x06,
0x00, 0x04, 0xf6, 0x18, 0x2c, 0x00, 0xfc, 0x06,
0x01, 0x02, 0xf7, 0x1f, 0x27, 0xfd, 0xff, 0x04,
0x03, 0x00, 0xf9, 0x24, 0x24, 0xf9, 0x00, 0x03,
0x04, 0xff, 0xfd, 0x29, 0x1d, 0xf7, 0x02, 0x01,
0x06, 0xfc, 0x00, 0x2d, 0x17, 0xf6, 0x04, 0x00,
0x06, 0xfa, 0x05, 0x30, 0x0f, 0xf7, 0x06, 0xff
}
},
{
.min = 1536,
.max = 2048,
.coef = {
0x05, 0xfd, 0xfb, 0x13, 0x25, 0x13, 0xfb, 0xfd,
0x05, 0xfc, 0xfd, 0x17, 0x24, 0x0f, 0xf9, 0xff,
0x04, 0xfa, 0xff, 0x1b, 0x24, 0x0b, 0xf9, 0x00,
0x03, 0xf9, 0x01, 0x1f, 0x23, 0x08, 0xf8, 0x01,
0x02, 0xf9, 0x04, 0x22, 0x20, 0x04, 0xf9, 0x02,
0x01, 0xf8, 0x08, 0x25, 0x1d, 0x01, 0xf9, 0x03,
0x00, 0xf9, 0x0c, 0x25, 0x1a, 0xfe, 0xfa, 0x04,
0xff, 0xf9, 0x10, 0x26, 0x15, 0xfc, 0xfc, 0x05
}
},
{
.min = 2048,
.max = 3072,
.coef = {
0xfc, 0xfd, 0x06, 0x13, 0x18, 0x13, 0x06, 0xfd,
0xfc, 0xfe, 0x08, 0x15, 0x17, 0x12, 0x04, 0xfc,
0xfb, 0xfe, 0x0a, 0x16, 0x18, 0x10, 0x03, 0xfc,
0xfb, 0x00, 0x0b, 0x18, 0x17, 0x0f, 0x01, 0xfb,
0xfb, 0x00, 0x0d, 0x19, 0x17, 0x0d, 0x00, 0xfb,
0xfb, 0x01, 0x0f, 0x19, 0x16, 0x0b, 0x00, 0xfb,
0xfc, 0x03, 0x11, 0x19, 0x15, 0x09, 0xfe, 0xfb,
0xfc, 0x04, 0x12, 0x1a, 0x12, 0x08, 0xfe, 0xfc
}
},
{
.min = 3072,
.max = 4096,
.coef = {
0xfe, 0x02, 0x09, 0x0f, 0x0e, 0x0f, 0x09, 0x02,
0xff, 0x02, 0x09, 0x0f, 0x10, 0x0e, 0x08, 0x01,
0xff, 0x03, 0x0a, 0x10, 0x10, 0x0d, 0x07, 0x00,
0x00, 0x04, 0x0b, 0x10, 0x0f, 0x0c, 0x06, 0x00,
0x00, 0x05, 0x0c, 0x10, 0x0e, 0x0c, 0x05, 0x00,
0x00, 0x06, 0x0c, 0x11, 0x0e, 0x0b, 0x04, 0x00,
0x00, 0x07, 0x0d, 0x11, 0x0f, 0x0a, 0x03, 0xff,
0x01, 0x08, 0x0e, 0x11, 0x0e, 0x09, 0x02, 0xff
}
},
{
.min = 4096,
.max = 5120,
.coef = {
0x00, 0x04, 0x09, 0x0c, 0x0e, 0x0c, 0x09, 0x04,
0x01, 0x05, 0x09, 0x0c, 0x0d, 0x0c, 0x08, 0x04,
0x01, 0x05, 0x0a, 0x0c, 0x0e, 0x0b, 0x08, 0x03,
0x02, 0x06, 0x0a, 0x0d, 0x0c, 0x0b, 0x07, 0x03,
0x02, 0x07, 0x0a, 0x0d, 0x0d, 0x0a, 0x07, 0x02,
0x03, 0x07, 0x0b, 0x0d, 0x0c, 0x0a, 0x06, 0x02,
0x03, 0x08, 0x0b, 0x0d, 0x0d, 0x0a, 0x05, 0x01,
0x04, 0x08, 0x0c, 0x0d, 0x0c, 0x09, 0x05, 0x01
}
},
{
.min = 5120,
.max = 65535,
.coef = {
0x03, 0x06, 0x09, 0x0b, 0x09, 0x0b, 0x09, 0x06,
0x03, 0x06, 0x09, 0x0b, 0x0c, 0x0a, 0x08, 0x05,
0x03, 0x06, 0x09, 0x0b, 0x0c, 0x0a, 0x08, 0x05,
0x04, 0x07, 0x09, 0x0b, 0x0b, 0x0a, 0x08, 0x04,
0x04, 0x07, 0x0a, 0x0b, 0x0b, 0x0a, 0x07, 0x04,
0x04, 0x08, 0x0a, 0x0b, 0x0b, 0x09, 0x07, 0x04,
0x05, 0x08, 0x0a, 0x0b, 0x0c, 0x09, 0x06, 0x03,
0x05, 0x08, 0x0a, 0x0b, 0x0c, 0x09, 0x06, 0x03
}
}
};

/**
* struct bdisp_filter_v_spec - Vertical filter specification
*
* @min: min scale factor for this filter (6.10 fixed point)
* @max: max scale factor for this filter (6.10 fixed point)
* coef: filter coefficients
*/
struct bdisp_filter_v_spec {
const u16 min;
const u16 max;
const u8 coef[BDISP_VF_NB];
};

static const struct bdisp_filter_v_spec bdisp_v_spec[] = {
{
.min = 0,
.max = 1024,
.coef = {
0x00, 0x00, 0x40, 0x00, 0x00,
0x00, 0x06, 0x3d, 0xfd, 0x00,
0xfe, 0x0f, 0x38, 0xfb, 0x00,
0xfd, 0x19, 0x2f, 0xfb, 0x00,
0xfc, 0x24, 0x24, 0xfc, 0x00,
0xfb, 0x2f, 0x19, 0xfd, 0x00,
0xfb, 0x38, 0x0f, 0xfe, 0x00,
0xfd, 0x3d, 0x06, 0x00, 0x00
}
},
{
.min = 1024,
.max = 1331,
.coef = {
0xfc, 0x05, 0x3e, 0x05, 0xfc,
0xf8, 0x0e, 0x3b, 0xff, 0x00,
0xf5, 0x18, 0x38, 0xf9, 0x02,
0xf4, 0x21, 0x31, 0xf5, 0x05,
0xf4, 0x2a, 0x27, 0xf4, 0x07,
0xf6, 0x30, 0x1e, 0xf4, 0x08,
0xf9, 0x35, 0x15, 0xf6, 0x07,
0xff, 0x37, 0x0b, 0xf9, 0x06
}
},
{
.min = 1331,
.max = 1433,
.coef = {
0xf8, 0x0a, 0x3c, 0x0a, 0xf8,
0xf6, 0x12, 0x3b, 0x02, 0xfb,
0xf4, 0x1b, 0x35, 0xfd, 0xff,
0xf4, 0x23, 0x30, 0xf8, 0x01,
0xf6, 0x29, 0x27, 0xf6, 0x04,
0xf9, 0x2e, 0x1e, 0xf5, 0x06,
0xfd, 0x31, 0x16, 0xf6, 0x06,
0x02, 0x32, 0x0d, 0xf8, 0x07
}
},
{
.min = 1433,
.max = 1536,
.coef = {
0xf6, 0x0e, 0x38, 0x0e, 0xf6,
0xf5, 0x15, 0x38, 0x06, 0xf8,
0xf5, 0x1d, 0x33, 0x00, 0xfb,
0xf6, 0x23, 0x2d, 0xfc, 0xfe,
0xf9, 0x28, 0x26, 0xf9, 0x00,
0xfc, 0x2c, 0x1e, 0xf7, 0x03,
0x00, 0x2e, 0x18, 0xf6, 0x04,
0x05, 0x2e, 0x11, 0xf7, 0x05
}
},
{
.min = 1536,
.max = 2048,
.coef = {
0xfb, 0x13, 0x24, 0x13, 0xfb,
0xfd, 0x17, 0x23, 0x0f, 0xfa,
0xff, 0x1a, 0x23, 0x0b, 0xf9,
0x01, 0x1d, 0x22, 0x07, 0xf9,
0x04, 0x20, 0x1f, 0x04, 0xf9,
0x07, 0x22, 0x1c, 0x01, 0xfa,
0x0b, 0x24, 0x17, 0xff, 0xfb,
0x0f, 0x24, 0x14, 0xfd, 0xfc
}
},
{
.min = 2048,
.max = 3072,
.coef = {
0x05, 0x10, 0x16, 0x10, 0x05,
0x06, 0x11, 0x16, 0x0f, 0x04,
0x08, 0x13, 0x15, 0x0e, 0x02,
0x09, 0x14, 0x16, 0x0c, 0x01,
0x0b, 0x15, 0x15, 0x0b, 0x00,
0x0d, 0x16, 0x13, 0x0a, 0x00,
0x0f, 0x17, 0x13, 0x08, 0xff,
0x11, 0x18, 0x12, 0x07, 0xfe
}
},
{
.min = 3072,
.max = 4096,
.coef = {
0x09, 0x0f, 0x10, 0x0f, 0x09,
0x09, 0x0f, 0x12, 0x0e, 0x08,
0x0a, 0x10, 0x11, 0x0e, 0x07,
0x0b, 0x11, 0x11, 0x0d, 0x06,
0x0c, 0x11, 0x12, 0x0c, 0x05,
0x0d, 0x12, 0x11, 0x0c, 0x04,
0x0e, 0x12, 0x11, 0x0b, 0x04,
0x0f, 0x13, 0x11, 0x0a, 0x03
}
},
{
.min = 4096,
.max = 5120,
.coef = {
0x0a, 0x0e, 0x10, 0x0e, 0x0a,
0x0b, 0x0e, 0x0f, 0x0e, 0x0a,
0x0b, 0x0f, 0x10, 0x0d, 0x09,
0x0c, 0x0f, 0x10, 0x0d, 0x08,
0x0d, 0x0f, 0x0f, 0x0d, 0x08,
0x0d, 0x10, 0x10, 0x0c, 0x07,
0x0e, 0x10, 0x0f, 0x0c, 0x07,
0x0f, 0x10, 0x10, 0x0b, 0x06
}
},
{
.min = 5120,
.max = 65535,
.coef = {
0x0b, 0x0e, 0x0e, 0x0e, 0x0b,
0x0b, 0x0e, 0x0f, 0x0d, 0x0b,
0x0c, 0x0e, 0x0f, 0x0d, 0x0a,
0x0c, 0x0e, 0x0f, 0x0d, 0x0a,
0x0d, 0x0f, 0x0e, 0x0d, 0x09,
0x0d, 0x0f, 0x0f, 0x0c, 0x09,
0x0e, 0x0f, 0x0e, 0x0c, 0x09,
0x0e, 0x0f, 0x0f, 0x0c, 0x08
}
}
};

#define NB_H_FILTER ARRAY_SIZE(bdisp_h_spec)
#define NB_V_FILTER ARRAY_SIZE(bdisp_v_spec)

/* RGB YUV 601 standard conversion */
static const u32 bdisp_rgb_to_yuv[] = {
0x0e1e8bee, 0x08420419, 0xfb5ed471, 0x08004080,
};

static const u32 bdisp_yuv_to_rgb[] = {
0x3324a800, 0xe604ab9c, 0x0004a957, 0x32121eeb,
};
Loading

0 comments on commit 28ffeeb

Please sign in to comment.