drm/exynos: add ipp subsystem and each ipp drivers
Subsystems (4)
cover drm/exynos: add ipp subsystem and each ipp drivers
Hi All.
I am responsible for a display part from Samsung Electronics Telecommunication Division. and I am going to add post-processing features in exynos drm.
If you have some opinions of this patch,
please give some comments about my patch.
This patch is post-processing(IPP) support for exynos drm driver.
IPP is stands for Image Post Processing and supports image scaler/rotator and input/output DMA operations using IPP drivers(FIMC, Rotator, GSC, SC, so on.) IPP is integration device driver of same attibute hardware.
Exynos4xxxx SoC support FIMC, Rotator for post-processing. and Exynos5xxxx SoC support GSC, Rotator, SC for post-processing. SC driver not tested yet. so, I didn't add SC feature in this patch. and IPP subsystem works on Exynos SoC version independently.
IPP drivers supports Memory to Memory operations with various converting. and some drivers supports Writeback and Display output operations using local path. User can make converted image using this driver.
and also supports streaming concept for multimedia data processing.
And supports various operations
1. Scale operation generates various sizes of image.
2. CSC(Color Space Conversion) operation supports format converting.
3. Crop operation supports cutting the image.
4. Rotate operation supports to 90, 180, 270 degree.
5. Flip operation supports to vertical, horizontal, and both.
6. Writeback operation genertates cloned image from display controller(FIMD).
7. Display output operation support various format display to display controller(FIMD).
8. Input DMA reads image data from the memory.
9. Output DMA writes image data to memory.
10. Supports image effect functions.
Descriptions)
User should make property informations and set this property to registers.
and IPP subsystem manages property id using command node and make queue list using memory node. IPP subsystem supports register function of IPP drivers.
IPP driver manages input/output DMA with various operations. and some driver supports optional operations(writeback, output).
IPP driver needs various informations, so User set property information to IPP driver. and also IPP driver needs memory base address of image for various operations. User doesn't know its address, so fills the gem handle of that memory than address of image base. and than IPP driver start operation.
Ioctls)
We adds four ioctls and one event for IPP subsystem.
- ioctlsDRM_EXYNOS_IPP_GET_PROPERTY : get ipp driver capabilitis and id. DRM_EXYNOS_IPP_SET_PROPERTY : set format, position, rotation, flip about source/destination. DRM_EXYNOS_IPP_QUEUE_BUF : enqueue/dequeue buffer and make event list. DRM_EXYNOS_IPP_CMD_CTRL : play/stop/pause/resume control.
- eventDRM_EXYNOS_IPP_EVENT : event to give notification completion of buffer DMA with buffer list
Basic control flow and Sample pseudo application)
1. Basic control flow is same as below
Open -> Get properties -> User choose IPP driver and set property information -> Set Property -> Create gem handle -> Queue buffer(Enqueue) of source/destination -> Command control(Play) -> Event occured to User
-> User handle converted image -> (Queue buffer(Enqueue) of source/destination -> Event occured to User)*N -> Queue buffer(Dequeue) of source/destination -> Command control(Stop) -> Free gem handle -> Close
2. Sample pseudo application
#include "exynos_drm.h"
static int exynos_drm_ipp_set_property(int fd ...)
{
struct drm_exynos_pos crop_pos = {0, 0, hsize, vsize};
struct drm_exynos_pos scale_pos = {0, 0, hsize, vsize};
struct drm_exynos_sz src_sz = {hsize, vsize};
struct drm_exynos_sz dst_sz = {hsize, vsize};
int ret = 0;
memset(property, 0x00, sizeof(struct drm_exynos_ipp_property));
property->cmd = cmd;
property->config[EXYNOS_DRM_OPS_SRC].ops_id = EXYNOS_DRM_OPS_SRC;
property->config[EXYNOS_DRM_OPS_SRC].flip = EXYNOS_DRM_FLIP_NONE;
property->config[EXYNOS_DRM_OPS_SRC].degree = EXYNOS_DRM_DEGREE_0;
property->config[EXYNOS_DRM_OPS_SRC].fmt = DRM_FORMAT_XRGB8888;
property->config[EXYNOS_DRM_OPS_SRC].pos = crop_pos;
property->config[EXYNOS_DRM_OPS_SRC].sz = src_sz;
property->config[EXYNOS_DRM_OPS_DST].ops_id = EXYNOS_DRM_OPS_DST;
property->config[EXYNOS_DRM_OPS_DST].flip = EXYNOS_DRM_FLIP_NONE;
property->config[EXYNOS_DRM_OPS_DST].degree = degree;
property->config[EXYNOS_DRM_OPS_DST].fmt = DRM_FORMAT_XRGB8888;
property->config[EXYNOS_DRM_OPS_DST].pos = scale_pos;
property->config[EXYNOS_DRM_OPS_DST].sz = dst_sz;
ret = ioctl(fd, DRM_IOCTL_EXYNOS_IPP_SET_PROPERTY, property);
if (ret)
fprintf(stderr,
"failed to DRM_IOCTL_EXYNOS_IPP_SET_PROPERTY : %s\n",
strerror(errno));
printf("DRM_IOCTL_EXYNOS_IPP_SET_PROPERTY : prop_id[%d]\n",
property->prop_id);
return ret;
}static int exynos_drm_ipp_queue_buf(int fd, ..., unsigned int gem_handle)
{
int ret = 0;
memset(qbuf, 0x00, sizeof(struct drm_exynos_ipp_queue_buf));
qbuf->ops_id = ops_id;
qbuf->buf = buf;
qbuf->user_data = 0;
qbuf->prop_id = prop_id;
qbuf->buf_id = buf_id;
qbuf->handle[EXYNOS_DRM_PLANAR_Y] = gem_handle;
qbuf->handle[EXYNOS_DRM_PLANAR_CB] = 0;
qbuf->handle[EXYNOS_DRM_PLANAR_CR] = 0;
ret = ioctl(fd, DRM_IOCTL_EXYNOS_IPP_QUEUE_BUF, qbuf);
if (ret)
fprintf(stderr,
"failed to DRM_IOCTL_EXYNOS_IPP_QUEUE_BUF[id:%d][buf:%d] : %s\n",
ops_id, buf, strerror(errno));
return ret;
}static int exynos_drm_ipp_cmd_ctrl(int fd, ...)
{
int ret = 0;
memset(cmd_ctrl, 0x00, sizeof(struct drm_exynos_ipp_cmd_ctrl));
cmd_ctrl->prop_id = prop_id;
cmd_ctrl->ctrl = ctrl;
ret = ioctl(fd, DRM_IOCTL_EXYNOS_IPP_CMD_CTRL, cmd_ctrl);
if (ret)
fprintf(stderr,
"failed to DRM_IOCTL_EXYNOS_IPP_CMD_CTRL[prop_id:%d][ctrl:%d] : %s\n",
prop_id, ctrl, strerror(errno));
return ret;
}int ipp_event_handler(...)
{
char buffer[1024];
int len, i;
struct drm_event *e;
struct drm_exynos_ipp_event *ipp_event;
char filename[100];
int ret = 0;
int src_buf_id, dst_buf_id;
static bmp_idx = 0;
len = read(fd, buffer, sizeof buffer);
if (len == 0)
return 0;
if (len < sizeof *e)
return -1;
i = 0;
while (i < len) {
e = (struct drm_event *) &buffer[i];
switch (e->type) {
case DRM_EXYNOS_IPP_EVENT:
ipp_event = (struct drm_exynos_ipp_event *) e;
src_buf_id = ipp_event->buf_id[EXYNOS_DRM_OPS_SRC];
dst_buf_id = ipp_event->buf_id[EXYNOS_DRM_OPS_DST];
/* For source buffer queue to IPP */
ret = exynos_drm_ipp_queue_buf(fd, &src_qbuf[src_buf_id], EXYNOS_DRM_OPS_SRC,
IPP_BUF_ENQUEUE, property->prop_id,
src_buf_id, src_gem[src_buf_id].handle);
if (ret) {
fprintf(stderr, "failed to ipp buf src queue\n");
goto err_ipp_ctrl_close;
}
/* For destination buffer queue to IPP */
ret = exynos_drm_ipp_queue_buf(fd, &dst_qbuf[dst_buf_id], EXYNOS_DRM_OPS_DST,
IPP_BUF_ENQUEUE, property->prop_id,
dst_buf_id, dst_gem[dst_buf_id].handle);
if (ret) {
fprintf(stderr, "failed to ipp buf dst queue\n");
goto err_ipp_ctrl_close;
}
break;
default:
break;
}
i += e->length;
}err_ipp_ctrl_close:
return ret; }
void ipp_main(...)
{
struct drm_exynos_ipp_property property;
struct drm_exynos_ipp_cmd_ctrl cmd_ctrl;
struct drm_exynos_sz def_sz = {720, 1280};
struct drm_exynos_ipp_queue_buf qbuf1[MAX_BUF], qbuf2[MAX_BUF];
unsigned int width=720, height=1280, stride;
int ret, i, j, x;
struct drm_exynos_gem_create gem1[MAX_BUF], gem2[MAX_BUF];
struct drm_exynos_gem_mmap mmap1[MAX_BUF], mmap2[MAX_BUF];
void *usr_addr1[MAX_BUF], *usr_addr2[MAX_BUF];
struct timeval begin, end;
struct drm_gem_close args;
char filename[100];
/* For property */
ret = exynos_drm_ipp_set_property(fd, &property, &def_sz, IPP_CMD_M2M, EXYNOS_DRM_DEGREE_0);
if (ret) {
fprintf(stderr, "failed to ipp property\n");
return;
}
for (i = 0; i < MAX_BUF; i++) {
/* For source buffer map to IPP */
ret = exynos_drm_ipp_queue_buf(fd, &qbuf1[i], EXYNOS_DRM_OPS_SRC,
IPP_BUF_ENQUEUE, property.prop_id, i, gem1[i].handle);
if (ret) {
fprintf(stderr, "failed to ipp buf src map\n");
goto err_ipp_ctrl_close;
}
}
for (i = 0; i < MAX_BUF; i++) {
/* For destination buffer map to IPP */
ret = exynos_drm_ipp_queue_buf(fd, &qbuf2[i], EXYNOS_DRM_OPS_DST,
IPP_BUF_ENQUEUE, property.prop_id, i, gem2[i].handle);
if (ret) {
fprintf(stderr, "failed to ipp buf dst map\n");
goto err_ipp_ctrl_close;
}
}
/* Start */
gettimeofday(&begin, NULL);
ret = exynos_drm_ipp_cmd_ctrl(fd, &cmd_ctrl, property.prop_id, IPP_CTRL_PLAY);
if (ret) {
fprintf(stderr,
"failed to ipp ctrl IPP_CMD_M2M start\n");
goto err_ipp_ctrl_close;
}
j=0;
while (1) {
struct timeval timeout = { .tv_sec = 3, .tv_usec = 0 };
fd_set fds;
FD_ZERO(&fds);
FD_SET(0, &fds);
FD_SET(fd, &fds);
ret = select(fd + 1, &fds, NULL, NULL, &timeout);
if (ret <= 0) {
fprintf(stderr, "select timed out or error.\n");
continue;
} else if (FD_ISSET(0, &fds)) {
break;
}
gettimeofday(&end, NULL);
usec[j] = (end.tv_sec - begin.tv_sec) * 1000000 +
(end.tv_usec - begin.tv_usec);
if(ipp_event_handler() < 0)
break;
if (++j > MAX_LOOP)
break;
gettimeofday(&begin, NULL);
}err_ipp_ctrl_close:
/* For source buffer dequeue to IPP */
for (i = 0; i < MAX_BUF; i++) {
ret = exynos_drm_ipp_queue_buf(fd, &qbuf1[i], EXYNOS_DRM_OPS_SRC,
IPP_BUF_DEQUEUE, property.prop_id, i, gem1[i].handle);
if (ret < 0)
fprintf(stderr, "failed to ipp buf dst dequeue\n");
}
/* For destination buffer dequeue to IPP */
for (i = 0; i < MAX_BUF; i++) {
ret = exynos_drm_ipp_queue_buf(fd, &qbuf2[i], EXYNOS_DRM_OPS_DST,
IPP_BUF_DEQUEUE, property.prop_id, i, gem2[i].handle);
if (ret < 0)
fprintf(stderr, "failed to ipp buf dst dequeue\n");
}
/* Stop */
ret = exynos_drm_ipp_cmd_ctrl(fd, &cmd_ctrl, property.prop_id, IPP_CTRL_STOP);
if (ret)
fprintf(stderr, "failed to ipp ctrl IPP_CMD_WB stop\n");
return;
}Eunchul Kim (4):
drm/exynos: add ipp subsystem
drm/exynos: add fimc ipp driver
drm/exynos: add rotator ipp driver
drm/exynos: add gsc ipp driver
drivers/gpu/drm/exynos/Kconfig | 24 + drivers/gpu/drm/exynos/Makefile | 4 + drivers/gpu/drm/exynos/exynos_drm_drv.c | 69 + drivers/gpu/drm/exynos/exynos_drm_drv.h | 10 + drivers/gpu/drm/exynos/exynos_drm_fimc.c | 2041 +++++++++++++++++++++++++++ drivers/gpu/drm/exynos/exynos_drm_fimc.h | 35 + drivers/gpu/drm/exynos/exynos_drm_gsc.c | 1476 +++++++++++++++++++ drivers/gpu/drm/exynos/exynos_drm_gsc.h | 35 + drivers/gpu/drm/exynos/exynos_drm_ipp.c | 1931 +++++++++++++++++++++++++ drivers/gpu/drm/exynos/exynos_drm_ipp.h | 268 ++++ drivers/gpu/drm/exynos/exynos_drm_rotator.c | 801 +++++++++++ drivers/gpu/drm/exynos/exynos_drm_rotator.h | 13 + drivers/gpu/drm/exynos/regs-fimc.h | 669 +++++++++ drivers/gpu/drm/exynos/regs-gsc.h | 295 ++++ drivers/gpu/drm/exynos/regs-rotator.h | 73 + include/drm/exynos_drm.h | 33 + include/uapi/drm/exynos_drm.h | 189 +++ 17 files changed, 7966 insertions(+), 0 deletions(-) create mode 100644 drivers/gpu/drm/exynos/exynos_drm_fimc.c create mode 100644 drivers/gpu/drm/exynos/exynos_drm_fimc.h create mode 100644 drivers/gpu/drm/exynos/exynos_drm_gsc.c create mode 100644 drivers/gpu/drm/exynos/exynos_drm_gsc.h create mode 100644 drivers/gpu/drm/exynos/exynos_drm_ipp.c create mode 100644 drivers/gpu/drm/exynos/exynos_drm_ipp.h create mode 100644 drivers/gpu/drm/exynos/exynos_drm_rotator.c create mode 100644 drivers/gpu/drm/exynos/exynos_drm_rotator.h create mode 100644 drivers/gpu/drm/exynos/regs-fimc.h create mode 100644 drivers/gpu/drm/exynos/regs-gsc.h create mode 100644 drivers/gpu/drm/exynos/regs-rotator.h
RFC 1/4 drm/exynos: add ipp subsystem
IPP stand for Image Post Processing and supports image scaler/rotator /crop/flip/csc(color space conversion) and input/output DMA operations using ipp drivers. also supports writeback and display output operations.
ipp driver include FIMC, Rotator, GSC, SC, so on.
and ipp is integration device driver for each hardware.
--- drivers/gpu/drm/exynos/Kconfig | 6 + drivers/gpu/drm/exynos/Makefile | 1 + drivers/gpu/drm/exynos/exynos_drm_drv.c | 24 + drivers/gpu/drm/exynos/exynos_drm_drv.h | 7 + drivers/gpu/drm/exynos/exynos_drm_ipp.c | 1933 +++++++++++++++++++++++++++++++ drivers/gpu/drm/exynos/exynos_drm_ipp.h | 268 +++++ include/uapi/drm/exynos_drm.h | 189 +++ 7 files changed, 2428 insertions(+), 0 deletions(-) create mode 100644 drivers/gpu/drm/exynos/exynos_drm_ipp.c create mode 100644 drivers/gpu/drm/exynos/exynos_drm_ipp.h
drivers/gpu/drm/exynos/Kconfig +6 -0
@@ -39,3 +39,9 @@ config DRM_EXYNOS_G2D depends on DRM_EXYNOS && !VIDEO_SAMSUNG_S5P_G2D help Choose this option if you want to use Exynos G2D for DRM. + +config DRM_EXYNOS_IPP + bool "Exynos DRM IPP" + depends on DRM_EXYNOS + help + Choose this option if you want to use IPP feature for DRM.
drivers/gpu/drm/exynos/Makefile +1 -0
@@ -15,5 +15,6 @@ exynosdrm-$(CONFIG_DRM_EXYNOS_HDMI) += exynos_hdmi.o exynos_mixer.o \ exynos_drm_hdmi.o exynosdrm-$(CONFIG_DRM_EXYNOS_VIDI) += exynos_drm_vidi.o exynosdrm-$(CONFIG_DRM_EXYNOS_G2D) += exynos_drm_g2d.o +exynosdrm-$(CONFIG_DRM_EXYNOS_IPP) += exynos_drm_ipp.o obj-$(CONFIG_DRM_EXYNOS) += exynosdrm.o
drivers/gpu/drm/exynos/exynos_drm_drv.c +24 -0
@@ -40,6 +40,7 @@#include "exynos_drm_vidi.h" #include "exynos_drm_dmabuf.h" #include "exynos_drm_g2d.h" +#include "exynos_drm_ipp.h" #define DRIVER_NAME "exynos"#define DRIVER_DESC "Samsung SoC DRM"
@@ -232,6 +233,14 @@ static struct drm_ioctl_desc exynos_ioctls[] = { exynos_g2d_set_cmdlist_ioctl, DRM_UNLOCKED | DRM_AUTH),DRM_IOCTL_DEF_DRV (EXYNOS_G2D_EXEC , exynos_g2d_exec_ioctl,DRM_UNLOCKED |DRM_AUTH ), +DRM_IOCTL_DEF_DRV (EXYNOS_IPP_GET_PROPERTY , + exynos_drm_ipp_get_property,DRM_UNLOCKED |DRM_AUTH ), +DRM_IOCTL_DEF_DRV (EXYNOS_IPP_SET_PROPERTY , + exynos_drm_ipp_set_property,DRM_UNLOCKED |DRM_AUTH ), +DRM_IOCTL_DEF_DRV (EXYNOS_IPP_QUEUE_BUF , + exynos_drm_ipp_queue_buf,DRM_UNLOCKED |DRM_AUTH ), +DRM_IOCTL_DEF_DRV (EXYNOS_IPP_CMD_CTRL , + exynos_drm_ipp_cmd_ctrl, DRM_UNLOCKED | DRM_AUTH), }; static const struct file_operations exynos_drm_driver_fops = {
@@ -346,6 +355,12 @@ static int __init exynos_drm_init(void) goto out_g2d;#endif +#ifdef CONFIG_DRM_EXYNOS_IPP + ret =platform_driver_register (&ipp_driver); +if (ret <0 ) + goto out_ipp; +#endif + ret =platform_driver_register (&exynos_drm_platform_driver);if (ret <0 ) goto out_drm;
@@ -363,6 +378,11 @@ out:platform_driver_unregister (&exynos_drm_platform_driver); out_drm: +#ifdef CONFIG_DRM_EXYNOS_IPP +platform_driver_unregister (&ipp_driver); +out_ipp: +#endif +#ifdef CONFIG_DRM_EXYNOS_G2D platform_driver_unregister (&g2d_driver); out_g2d:
@@ -399,6 +419,10 @@ static void __exit exynos_drm_exit(void)platform_driver_unregister (&exynos_drm_platform_driver); +#ifdef CONFIG_DRM_EXYNOS_IPP +platform_driver_unregister (&ipp_driver); +#endif +#ifdef CONFIG_DRM_EXYNOS_G2D platform_driver_unregister (&g2d_driver);#endif
drivers/gpu/drm/exynos/exynos_drm_drv.h +7 -0
@@ -235,8 +235,14 @@ struct exynos_drm_g2d_private {unsigned int gem_nr; }; +struct exynos_drm_ipp_private { +struct device *dev; +struct list_head event_list; +}; +struct drm_exynos_file_private {struct exynos_drm_g2d_private *g2d_priv; +struct exynos_drm_ipp_private *ipp_priv; };/*
@@ -335,4 +341,5 @@ extern struct platform_driver mixer_driver;extern struct platform_driver exynos_drm_common_hdmi_driver;extern struct platform_driver vidi_driver;extern struct platform_driver g2d_driver; +extern struct platform_driver ipp_driver;#endif
drivers/gpu/drm/exynos/exynos_drm_ipp.c new file +1933 -0
1,933 lines not on this page · raw message
drivers/gpu/drm/exynos/exynos_drm_ipp.h new file +268 -0
268 lines not on this page · raw message
include/uapi/drm/exynos_drm.h +189 -0
213 lines not on this page · raw message
Signature · 1 line
1.7.0.4
Inki Dae
maintainerRE: [RFC 1/4] drm/exynos: add ipp subsystem
Enchul, let's add comments enough first. Other guys couldn't afford to review your patch if you don't provide comments enough because they should analyze your patch set spending their efforts. And please rebase them to be based on exynos-drm-next.
Below is a little bit comments. Please, describe your codes as much as possible.
Thanks,
Inki Dae
Quoted 73 lines
-----Original Message-----
From: Eunchul Kim [mailto:[email protected]]
Sent: Monday, October 29, 2012 10:11 PM
To: [email protected]; [email protected]
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: [RFC 1/4] drm/exynos: add ipp subsystemIPP stand for Image Post Processing and supports image scaler/rotator /crop/flip/csc(color space conversion) and input/output DMA operations using ipp drivers.
also supports writeback and display output operations.
ipp driver include FIMC, Rotator, GSC, SC, so on.
and ipp is integration device driver for each hardware.Signed-off-by Eunchul Kim <[email protected]>Signed-off-by Jinyoung Jeon <[email protected]>--- drivers/gpu/drm/exynos/Kconfig | 6 + drivers/gpu/drm/exynos/Makefile | 1 + drivers/gpu/drm/exynos/exynos_drm_drv.c | 24 + drivers/gpu/drm/exynos/exynos_drm_drv.h | 7 + drivers/gpu/drm/exynos/exynos_drm_ipp.c | 1933 +++++++++++++++++++++++++++++++ drivers/gpu/drm/exynos/exynos_drm_ipp.h | 268 +++++ include/uapi/drm/exynos_drm.h | 189 +++ 7 files changed, 2428 insertions(+), 0 deletions(-) create mode 100644 drivers/gpu/drm/exynos/exynos_drm_ipp.c create mode 100644 drivers/gpu/drm/exynos/exynos_drm_ipp.hdrivers/gpu/drm/exynos/Kconfig +6
-0@@ -39,3 +39,9 @@ config DRM_EXYNOS_G2D depends on DRM_EXYNOS && !VIDEO_SAMSUNG_S5P_G2D help Choose this option if you want to use Exynos G2D for DRM. + +config DRM_EXYNOS_IPP + bool "Exynos DRM IPP" + depends on DRM_EXYNOS + help + Choose this option if you want to use IPP feature for DRM.drivers/gpu/drm/exynos/Makefile +1
-0@@ -15,5 +15,6 @@ exynosdrm-$(CONFIG_DRM_EXYNOS_HDMI) += exynos_hdmi.o exynos_mixer.o \ exynos_drm_hdmi.o exynosdrm-$(CONFIG_DRM_EXYNOS_VIDI) += exynos_drm_vidi.o exynosdrm-$(CONFIG_DRM_EXYNOS_G2D) += exynos_drm_g2d.o +exynosdrm-$(CONFIG_DRM_EXYNOS_IPP) += exynos_drm_ipp.oobj-$(CONFIG_DRM_EXYNOS) += exynosdrm.o
drivers/gpu/drm/exynos/exynos_drm_drv.c +1
-0@@ -40,6 +40,7 @@#include "exynos_drm_vidi.h" #include "exynos_drm_dmabuf.h" #include "exynos_drm_g2d.h" +#include "exynos_drm_ipp.h" #define DRIVER_NAME "exynos"#define DRIVER_DESC "Samsung SoC DRM"
drivers/gpu/drm/exynos/exynos_drm_drv.c static struct drm_ioctl_desc exynos_ioctls[] = { · line 233
Quoted 1 line
drivers/gpu/drm/exynos/exynos_drm_drv.c +0
-0@@ -232,6 +233,14 @@ static struct drm_ioctl_desc exynos_ioctls[] = { exynos_g2d_set_cmdlist_ioctl, DRM_UNLOCKED |
DRM_AUTH),
drivers/gpu/drm/exynos/exynos_drm_drv.c static struct drm_ioctl_desc exynos_ioctls[] = {
Quoted 4 lines
drivers/gpu/drm/exynos/exynos_drm_drv.c +2
-0DRM_IOCTL_DEF_DRV (EXYNOS_G2D_EXEC , exynos_g2d_exec_ioctl,DRM_UNLOCKED |DRM_AUTH ), + DRM_IOCTL_DEF_DRV(EXYNOS_IPP_GET_PROPERTY, + exynos_drm_ipp_get_property, DRM_UNLOCKED |
DRM_AUTH),
drivers/gpu/drm/exynos/exynos_drm_drv.c static struct drm_ioctl_desc exynos_ioctls[] = { · line 239
Quoted 2 lines
drivers/gpu/drm/exynos/exynos_drm_drv.c +2
-0+ DRM_IOCTL_DEF_DRV(EXYNOS_IPP_SET_PROPERTY, + exynos_drm_ipp_set_property, DRM_UNLOCKED |
DRM_AUTH),
Quoted 312 lines
drivers/gpu/drm/exynos/exynos_drm_drv.c +19
-0+DRM_IOCTL_DEF_DRV (EXYNOS_IPP_QUEUE_BUF , + exynos_drm_ipp_queue_buf,DRM_UNLOCKED |DRM_AUTH ), +DRM_IOCTL_DEF_DRV (EXYNOS_IPP_CMD_CTRL , + exynos_drm_ipp_cmd_ctrl, DRM_UNLOCKED | DRM_AUTH), }; static const struct file_operations exynos_drm_driver_fops = {@@ -346,6 +355,12 @@ static int __init exynos_drm_init(void) goto out_g2d;#endif +#ifdef CONFIG_DRM_EXYNOS_IPP + ret =platform_driver_register (&ipp_driver); +if (ret <0 ) + goto out_ipp; +#endif + ret =platform_driver_register (&exynos_drm_platform_driver);if (ret <0 ) goto out_drm;@@ -363,6 +378,11 @@ out:platform_driver_unregister (&exynos_drm_platform_driver); out_drm: +#ifdef CONFIG_DRM_EXYNOS_IPP +platform_driver_unregister (&ipp_driver); +out_ipp: +#endif +#ifdef CONFIG_DRM_EXYNOS_G2D platform_driver_unregister (&g2d_driver); out_g2d:@@ -399,6 +419,10 @@ static void __exit exynos_drm_exit(void)platform_driver_unregister (&exynos_drm_platform_driver); +#ifdef CONFIG_DRM_EXYNOS_IPP +platform_driver_unregister (&ipp_driver); +#endif +#ifdef CONFIG_DRM_EXYNOS_G2D platform_driver_unregister (&g2d_driver);#endif drivers/gpu/drm/exynos/exynos_drm_drv.h +7
-0@@ -235,8 +235,14 @@ struct exynos_drm_g2d_private {unsigned int gem_nr; }; +struct exynos_drm_ipp_private { +struct device *dev; +struct list_head event_list; +}; +struct drm_exynos_file_private {struct exynos_drm_g2d_private *g2d_priv; +struct exynos_drm_ipp_private *ipp_priv; };/* @@ -335,4 +341,5 @@ extern struct platform_driver mixer_driver;extern struct platform_driver exynos_drm_common_hdmi_driver;extern struct platform_driver vidi_driver;extern struct platform_driver g2d_driver; +extern struct platform_driver ipp_driver;#endif drivers/gpu/drm/exynos/exynos_drm_ipp.c new file +8
-0@@ -0,0 +1,1933 @@ +/* +* Copyright (C) 2012 Samsung Electronics Co.Ltd +* Authors: +* Eunchul Kim <[email protected]> +* Jinyoung Jeon <[email protected]> +* Sangmin Lee <[email protected]> +* +* This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; either version 2 of the License, or (at your
+ * option) any later version.
+ *
+ */drivers/gpu/drm/exynos/exynos_drm_ipp.c new file +21
-0+#include <linux/kernel.h> +#include <linux/module.h> +#include <linux/platform_device.h> +#include <linux/clk.h> +#include <linux/pm_runtime.h> +#include <plat/map-base.h> + +#include <drm/drmP.h> +#include <drm/exynos_drm.h> +#include "exynos_drm_drv.h" +#include "exynos_drm_gem.h" +#include "exynos_drm_ipp.h" + +/* +* IPP is stand for Image Post Processing and +* supports image scaler/rotator and input/output DMA operations. +* using FIMC, GSC, Rotator, so on. +* IPP is integration device driver of same attribute h/w +*/ + +#define get_ipp_context (dev)platform_get_drvdata(to_platform_device(dev))
drivers/gpu/drm/exynos/exynos_drm_ipp.c new file +74
-0+ +/* +* A structure of event. +* +* @base: base of event. +* @event: ipp event. +*/ +struct drm_exynos_ipp_send_event { +struct drm_pending_event base; +struct drm_exynos_ipp_event event; +}; + +/* +* A structure of memory node. +* +* @list: list head to memory queue information. +* @ops_id: id of operations. +* @prop_id: id of property. +* @buf_id: id of buffer. +* @buf_info: gem objects and dma address, size. +*/ +struct drm_exynos_ipp_mem_node { +struct list_head list; +enum drm_exynos_ops_id ops_id; +u32 prop_id; +u32 buf_id; +struct drm_exynos_ipp_buf_info buf_info; +}; + +/* +* A structure of ipp context. +* +* @subdrv: prepare initialization using subdrv. +* @ipp_lock: lock for synchronization of access to ipp_idr. +* @prop_lock: lock for synchronization of access to prop_idr. +* @ipp_idr: ipp driver idr. +* @prop_idr: property idr. +* @event_workq: event work queue. +* @cmd_workq: command work queue. +*/ +struct ipp_context { +struct exynos_drm_subdrv subdrv; +struct mutex ipp_lock; +struct mutex prop_lock; +struct idr ipp_idr; +struct idr prop_idr; +struct workqueue_struct *event_workq; +struct workqueue_struct *cmd_workq; +}; + +static LIST_HEAD (exynos_drm_ippdrv_list); +static BLOCKING_NOTIFIER_HEAD (exynos_drm_ippnb_list); + +int exynos_drm_ippdrv_register (struct exynos_drm_ippdrv *ippdrv) +{ +DRM_DEBUG_KMS ("%s\n" , __func__); + +list_add_tail (&ippdrv->drv_list, &exynos_drm_ippdrv_list); + +return 0 ; +} +EXPORT_SYMBOL_GPL (exynos_drm_ippdrv_register); + +int exynos_drm_ippdrv_unregister (struct exynos_drm_ippdrv *ippdrv) +{ +DRM_DEBUG_KMS ("%s\n" , __func__); + +list_del (&ippdrv->drv_list); + +return 0 ; +} +EXPORT_SYMBOL_GPL (exynos_drm_ippdrv_unregister); + +static int ipp_create_id(struct idr *id_idr, struct mutex *lock, void*obj,
drivers/gpu/drm/exynos/exynos_drm_ipp.c new file +81
-0+ u32 *idp) +{ +int ret = -EINVAL ; + +DRM_DEBUG_KMS ("%s\n" , __func__); + +again: +/* ensure there is space available to allocate a handle */ +if (idr_pre_get (id_idr,GFP_KERNEL ) ==0 ) +return -ENOMEM ; + +/* do the allocation under our mutexlock */ +mutex_lock (lock); + ret =idr_get_new_above (id_idr, obj,1 , (int *)idp); +mutex_unlock (lock); +if (ret == -EAGAIN ) + goto again; + +return ret; +} + +static void *ipp_find_id (struct idr *id_idr,struct mutex *lock,u32 id) +{ +void *obj; + +DRM_DEBUG_KMS ("%s:id[%d]\n" , __func__, id); + +mutex_lock (lock); + +/* find object using handle */ + obj =idr_find (id_idr, id); +if (obj ==NULL ) { +mutex_unlock (lock); +return NULL ; + } + +mutex_unlock (lock); + +return obj; +} + +static struct exynos_drm_ippdrv *ipp_find_driver (struct ipp_context *ctx, +struct drm_exynos_ipp_property *property) +{ +struct exynos_drm_ippdrv *ippdrv; +u32 ipp_id = property->ipp_id; + +DRM_DEBUG_KMS ("%s:ipp_id[%d]\n" , __func__, ipp_id); + +if (ipp_id) { +/* find ipp driver */ + ippdrv =ipp_find_id (&ctx->ipp_idr, &ctx->ipp_lock, + ipp_id); +if (!ippdrv) { +DRM_ERROR ("not found ipp%d driver.\n" , ipp_id); + goto err_null; + } + +/* check dedicated state */ +if (ippdrv->dedicated) { +DRM_ERROR ("used choose device.\n" ); + goto err_null; + } + +if (property->cmd !=IPP_CMD_M2M + && !pm_runtime_suspended (ippdrv->dev)) { +DRM_ERROR ("can't run dedicatedly.\n" ); + goto err_null; + } + +/* check property */ +if (ippdrv->check_property && + ippdrv->check_property (ippdrv->dev, property)) { +DRM_ERROR ("not support property.\n" ); + goto err_null; + } + +return ippdrv; + }else { +/* get ipp driver entry */ + list_for_each_entry(ippdrv, &exynos_drm_ippdrv_list,
drv_list) {drivers/gpu/drm/exynos/exynos_drm_ipp.c new file +41
-0+/* check dedicated state */ +if (ippdrv->dedicated) +continue ; + +if (property->cmd !=IPP_CMD_M2M + && !pm_runtime_suspended (ippdrv->dev)) { +DRM_DEBUG_KMS ("%s:can't run dedicatedly.\n" , + __func__); +continue ; + } + +/* check property */ +if (ippdrv->check_property && + ippdrv->check_property (ippdrv->dev, property)) { +DRM_DEBUG_KMS ("%s:not support property.\n" , + __func__); +continue ; + } + +return ippdrv; + } + +DRM_ERROR ("not support ipp driver operations.\n" ); + } + +return ERR_PTR (-ENODEV ); + +err_null: +return NULL ; +} + +static struct exynos_drm_ippdrv *ipp_find_drv_node (u32 prop_id) +{ +struct exynos_drm_ippdrv *ippdrv; +struct drm_exynos_ipp_cmd_node *c_node; +int count =0 ; + +DRM_DEBUG_KMS ("%s:prop_id[%d]\n" , __func__, prop_id); + +if (list_empty (&exynos_drm_ippdrv_list)) { + DRM_DEBUG_KMS("%s:ippdrv_list is empty.\n",
drivers/gpu/drm/exynos/exynos_drm_ipp.c
Quoted 10 lines
drivers/gpu/drm/exynos/exynos_drm_ipp.c new file +10
-0+ __func__); +return NULL ; + } + +list_for_each_entry (ippdrv, &exynos_drm_ippdrv_list, drv_list) { +DRM_DEBUG_KMS ("%s:count[%d]ippdrv[0x%x]\n" , + __func__, count++, (int )ippdrv); + +if (!list_empty (&ippdrv->cmd_list)) { +list_for_each_entry (c_node, &ippdrv->cmd_list, list)
{
Quoted 99 lines
drivers/gpu/drm/exynos/exynos_drm_ipp.c new file +36
-0+if (c_node->property.prop_id == prop_id) +return ippdrv; + } + } + } + +return NULL ; +} + +int exynos_drm_ipp_get_property (struct drm_device *drm_dev,void *data, +struct drm_file *file) +{ +struct drm_exynos_file_private *file_priv = file->driver_priv; +struct exynos_drm_ipp_private *priv = file_priv->ipp_priv; +struct device *dev = priv->dev; +struct ipp_context *ctx =get_ipp_context (dev); +struct drm_exynos_ipp_prop_list *prop_list = data; +struct exynos_drm_ippdrv *ippdrv; +int count =0 ; + +DRM_DEBUG_KMS ("%s\n" , __func__); + +if (!ctx) { +DRM_ERROR ("invalid context.\n" ); +return -EINVAL ; + } + +if (!prop_list) { +DRM_ERROR ("invalid property parameter.\n" ); +return -EINVAL ; + } + +DRM_DEBUG_KMS ("%s:ipp_id[%d]\n" , __func__, prop_list->ipp_id); + +if (prop_list->ipp_id ==0 ) { + list_for_each_entry(ippdrv, &exynos_drm_ippdrv_list,
drv_list)drivers/gpu/drm/exynos/exynos_drm_ipp.c new file +62
-0+ count++; + prop_list->count = count; + }else { + ippdrv =ipp_find_id (&ctx->ipp_idr, &ctx->ipp_lock, + prop_list->ipp_id); + +if (!ippdrv) { +DRM_ERROR ("not found ipp%d driver.\n" , + prop_list->ipp_id); +return -EINVAL ; + } + + prop_list = ippdrv->prop_list; + } + +return 0 ; +} +EXPORT_SYMBOL_GPL (exynos_drm_ipp_get_property); + +int exynos_drm_ipp_set_property (struct drm_device *drm_dev,void *data, +struct drm_file *file) +{ +struct drm_exynos_file_private *file_priv = file->driver_priv; +struct exynos_drm_ipp_private *priv = file_priv->ipp_priv; +struct device *dev = priv->dev; +struct ipp_context *ctx =get_ipp_context (dev); +struct drm_exynos_ipp_property *property = data; +struct exynos_drm_ippdrv *ippdrv; +struct drm_exynos_ipp_cmd_node *c_node; +struct drm_exynos_ipp_config *config; +struct drm_exynos_pos *pos; +struct drm_exynos_sz *sz; +int ret, i; + +DRM_DEBUG_KMS ("%s\n" , __func__); + +if (!ctx) { +DRM_ERROR ("invalid context.\n" ); +return -EINVAL ; + } + +if (!property) { +DRM_ERROR ("invalid property parameter.\n" ); +return -EINVAL ; + } + +for_each_ipp_ops (i) { + config = &property->config[i]; + pos = &config->pos; + sz = &config->sz; + +DRM_DEBUG_KMS ("%s:prop_id[%d]ops[%s]fmt[0x%x]\n" , + __func__, property->prop_id, + i ?"dst" :"src" , config->fmt); + +DRM_DEBUG_KMS ("%s:pos[%d %d %d %d]sz[%d %d]f[%d]r[%d]\n" , + __func__, pos->x, pos->y, pos->w, pos->h, + sz->hsize, sz->vsize, config->flip, config->degree); + } + +if (property->prop_id) { + ippdrv =ipp_find_drv_node (property->prop_id);
drivers/gpu/drm/exynos/exynos_drm_ipp.c
Quoted 10 lines
drivers/gpu/drm/exynos/exynos_drm_ipp.c new file +10
-0+if (!ippdrv) { +DRM_ERROR ("failed to get ipp driver.\n" ); +return -EINVAL ; + } + +list_for_each_entry (c_node, &ippdrv->cmd_list, list) { +if ((c_node->property.prop_id == + property->prop_id) && + (c_node->state ==IPP_STATE_STOP )) { + DRM_DEBUG_KMS("%s:found
cmd[%d]ippdrv[0x%x]\n",
drivers/gpu/drm/exynos/exynos_drm_ipp.c
Quoted 1 line
drivers/gpu/drm/exynos/exynos_drm_ipp.c new file +1
-0+ __func__, property->cmd,
(int)ippdrv);
Quoted 275 lines
drivers/gpu/drm/exynos/exynos_drm_ipp.c new file +153
-0+ + c_node->property = *property; +return 0 ; + } + } + +DRM_ERROR ("failed to search property.\n" ); +return -EINVAL ; + } + +/* find ipp driver using ipp id */ + ippdrv =ipp_find_driver (ctx, property); +if (IS_ERR_OR_NULL (ippdrv)) { +DRM_ERROR ("failed to get ipp driver.\n" ); +return -EINVAL ; + } + +/* allocate command node */ + c_node =kzalloc (sizeof (*c_node),GFP_KERNEL ); +if (!c_node) { +DRM_ERROR ("failed to allocate map node.\n" ); +return -ENOMEM ; + } + +/* create property id */ + ret =ipp_create_id (&ctx->prop_idr, &ctx->prop_lock, c_node, + &property->prop_id); +if (ret) { +DRM_ERROR ("failed to create id.\n" ); + goto err_clear; + } + +DRM_DEBUG_KMS ("%s:created prop_id[%d]cmd[%d]ippdrv[0x%x]\n" , + __func__, property->prop_id, property->cmd, (int )ippdrv); + +/* stored property information and ippdrv in private data */ + c_node->priv = priv; + c_node->property = *property; + c_node->state =IPP_STATE_IDLE ; + + c_node->start_work =kzalloc (sizeof (*c_node->start_work), +GFP_KERNEL ); +if (!c_node->start_work) { +DRM_ERROR ("failed to alloc start_work.\n" ); + ret = -ENOMEM ; + goto err_clear; + } + +INIT_WORK ((struct work_struct *)c_node->start_work, + ipp_sched_cmd); + + c_node->stop_work =kzalloc (sizeof (*c_node->stop_work), +GFP_KERNEL ); +if (!c_node->stop_work) { +DRM_ERROR ("failed to alloc stop_work.\n" ); + ret = -ENOMEM ; + goto err_free_start; + } + +INIT_WORK ((struct work_struct *)c_node->stop_work, + ipp_sched_cmd); + + c_node->event_work =kzalloc (sizeof (*c_node->event_work), +GFP_KERNEL ); +if (!c_node->event_work) { +DRM_ERROR ("failed to alloc event_work.\n" ); + ret = -ENOMEM ; + goto err_free_stop; + } + +INIT_WORK ((struct work_struct *)c_node->event_work, + ipp_sched_event); + +/* init ioctl lock */ +mutex_init (&c_node->cmd_lock); +mutex_init (&c_node->mem_lock); +mutex_init (&c_node->event_lock); +init_completion (&c_node->start_complete); +init_completion (&c_node->stop_complete); + +for_each_ipp_ops (i) +INIT_LIST_HEAD (&c_node->mem_list[i]); + +INIT_LIST_HEAD (&c_node->event_list); +list_splice_init (&priv->event_list, &c_node->event_list); +list_add_tail (&c_node->list, &ippdrv->cmd_list); + +/* make dedicated state without m2m */ +if (property->cmd !=IPP_CMD_M2M ) + ippdrv->dedicated = true; + +return 0 ; + +err_free_stop: +kfree (c_node->stop_work); +err_free_start: +kfree (c_node->start_work); +err_clear: +kfree (c_node); +return ret; +} +EXPORT_SYMBOL_GPL (exynos_drm_ipp_set_property); + +static struct drm_exynos_ipp_mem_node + *ipp_find_mem_node (struct drm_exynos_ipp_cmd_node *c_node, +struct drm_exynos_ipp_queue_buf *qbuf) +{ +struct drm_exynos_ipp_mem_node *m_node; +struct list_head *head; +int count =0 ; + +DRM_DEBUG_KMS ("%s:buf_id[%d]\n" , __func__, qbuf->buf_id); + +/* source/destination memory list */ + head = &c_node->mem_list[qbuf->ops_id]; + +/* find memory node entry */ +list_for_each_entry (m_node, head, list) { +DRM_DEBUG_KMS ("%s:count[%d]m_node[0x%x]\n" , + __func__, count++, (int )m_node); + +/* compare buffer id */ +if (m_node->buf_id == qbuf->buf_id) +return m_node; + } + +return NULL ; +} + +static int ipp_check_mem_list (struct drm_exynos_ipp_cmd_node *c_node) +{ +struct drm_exynos_ipp_property *property = &c_node->property; +struct drm_exynos_ipp_mem_node *m_node; +struct list_head *head; +int ret, i, count[EXYNOS_DRM_OPS_MAX ] = {0 , }; + +DRM_DEBUG_KMS ("%s\n" , __func__); + +mutex_lock (&c_node->mem_lock); + +for_each_ipp_ops (i) { +/* source/destination memory list */ + head = &c_node->mem_list[i]; + +if (list_empty (head)) { +DRM_DEBUG_KMS ("%s:%s memory empty.\n" , __func__, + i ?"dst" :"src" ); +continue ; + } + +/* find memory node entry */ +list_for_each_entry (m_node, head, list) { + DRM_DEBUG_KMS("%s:%s,count[%d]m_node[0x%x]\n",
__func__,drivers/gpu/drm/exynos/exynos_drm_ipp.c new file +121
-0+ i ? "dst" : "src", count[i], (int)m_node); + count[i]++; + } + } + +DRM_DEBUG_KMS ("%s:min[%d]max[%d]\n" , __func__, +min (count[EXYNOS_DRM_OPS_SRC ], count[EXYNOS_DRM_OPS_DST ]), +max (count[EXYNOS_DRM_OPS_SRC ], count[EXYNOS_DRM_OPS_DST ])); + + +if (property->cmd ==IPP_CMD_M2M ) + ret =min (count[EXYNOS_DRM_OPS_SRC ], + count[EXYNOS_DRM_OPS_DST ]); +else + ret =max (count[EXYNOS_DRM_OPS_SRC ], + count[EXYNOS_DRM_OPS_DST ]); + +mutex_unlock (&c_node->mem_lock); + +return ret; +} + +static void ipp_clean_cmd_node (struct drm_exynos_ipp_cmd_node *c_node) +{ +DRM_DEBUG_KMS ("%s\n" , __func__); + +/* delete list */ +list_del (&c_node->list); + +/* destroy mutex */ +mutex_destroy (&c_node->cmd_lock); +mutex_destroy (&c_node->mem_lock); +mutex_destroy (&c_node->event_lock); + +/* free command node */ +kfree (c_node->start_work); +kfree (c_node->stop_work); +kfree (c_node->event_work); +kfree (c_node); +} + +static int ipp_set_mem_node (struct exynos_drm_ippdrv *ippdrv, +struct drm_exynos_ipp_cmd_node *c_node, +struct drm_exynos_ipp_mem_node *m_node) +{ +struct exynos_drm_ipp_ops *ops =NULL ; +int ret =0 ; + +DRM_DEBUG_KMS ("%s:node[0x%x]\n" , __func__, (int )m_node); + +if (!m_node) { +DRM_ERROR ("invalid queue node.\n" ); +return -EFAULT ; + } + +mutex_lock (&c_node->mem_lock); + +DRM_DEBUG_KMS ("%s:ops_id[%d]\n" , __func__, m_node->ops_id); + +/* get operations callback */ + ops = ippdrv->ops[m_node->ops_id]; +if (!ops) { +DRM_ERROR ("not support ops.\n" ); + ret = -EFAULT ; + goto err_unlock; + } + +/* set address and enable irq */ +if (ops->set_addr) { + ret = ops->set_addr (ippdrv->dev, &m_node->buf_info, + m_node->buf_id,IPP_BUF_ENQUEUE ); +if (ret) { +DRM_ERROR ("failed to set addr.\n" ); + goto err_unlock; + } + } + +err_unlock: +mutex_unlock (&c_node->mem_lock); +return ret; +} + +static struct drm_exynos_ipp_mem_node + *ipp_get_mem_node (struct drm_device *drm_dev, +struct drm_file *file, +struct drm_exynos_ipp_cmd_node *c_node, +struct drm_exynos_ipp_queue_buf *qbuf) +{ +struct drm_exynos_ipp_mem_node *m_node; +struct drm_exynos_ipp_buf_info buf_info; +void *addr; +int i; + +mutex_lock (&c_node->mem_lock); + + m_node =kzalloc (sizeof (*m_node),GFP_KERNEL ); +if (!m_node) { +DRM_ERROR ("failed to allocate queue node.\n" ); + goto err_unlock; + } + +/* clear base address for error handling */ +memset (&buf_info,0x0 ,sizeof (buf_info)); + +/* operations, buffer id */ + m_node->ops_id = qbuf->ops_id; + m_node->prop_id = qbuf->prop_id; + m_node->buf_id = qbuf->buf_id; + +DRM_DEBUG_KMS ("%s:m_node[0x%x]ops_id[%d]\n" , __func__, + (int )m_node, qbuf->ops_id); +DRM_DEBUG_KMS ("%s:prop_id[%d]buf_id[%d]\n" , __func__, + qbuf->prop_id, m_node->buf_id); + +for_each_ipp_planar (i) { +DRM_DEBUG_KMS ("%s:i[%d]handle[0x%x]\n" , __func__, + i, qbuf->handle[i]); + +/* get dma address by handle */ +if (qbuf->handle[i] !=0 ) { + addr = exynos_drm_gem_get_dma_addr(drm_dev,
drivers/gpu/drm/exynos/exynos_drm_ipp.c line 638
Quoted 10 lines
drivers/gpu/drm/exynos/exynos_drm_ipp.c new file +10
-0+ qbuf->handle[i], file); +if (!addr) { +DRM_ERROR ("failed to get addr.\n" ); + goto err_clear; + } + + buf_info.gem_handle[i] = qbuf->handle[i]; + buf_info.base[i] = *(dma_addr_t *) addr; + buf_info.file = file; +
DRM_DEBUG_KMS("%s:i[%d]base[0x%x]gem_handle[0x%x]\n",
Quoted 39 lines
drivers/gpu/drm/exynos/exynos_drm_ipp.c new file +39
-0+ __func__, i, buf_info.base[i], + buf_info.gem_handle[i]); + } + } + + m_node->buf_info = buf_info; +list_add_tail (&m_node->list, &c_node->mem_list[qbuf->ops_id]); + +mutex_unlock (&c_node->mem_lock); +return m_node; + +err_clear: +kfree (m_node); + +err_unlock: +mutex_unlock (&c_node->mem_lock); + +return NULL ; +} + +static int ipp_put_mem_node (struct drm_device *drm_dev, +struct drm_exynos_ipp_cmd_node *c_node, +struct drm_exynos_ipp_mem_node *m_node) +{ +int i, ret =0 ; + +DRM_DEBUG_KMS ("%s:node[0x%x]\n" , __func__, (int )m_node); + +if (!m_node) { +DRM_ERROR ("invalid dequeue node.\n" ); +return -EFAULT ; + } + +if (list_empty (&m_node->list)) { +DRM_ERROR ("empty memory node.\n" ); +return -ENOMEM ; + } + +mutex_lock (&c_node->mem_lock);
drivers/gpu/drm/exynos/exynos_drm_ipp.c
Quoted 10 lines
drivers/gpu/drm/exynos/exynos_drm_ipp.c new file +10
-0+ +DRM_DEBUG_KMS ("%s:ops_id[%d]\n" , __func__, m_node->ops_id); + +/* put gem buffer */ +for_each_ipp_planar (i) { +struct drm_file *file = m_node->buf_info.file; +unsigned int gem_handle = m_node->buf_info.gem_handle[i]; + +if (gem_handle) + exynos_drm_gem_put_dma_addr(drm_dev, gem_handle,
file);
Quoted 162 lines
drivers/gpu/drm/exynos/exynos_drm_ipp.c new file +162
-0+ } + +/* delete list in queue */ +list_del (&m_node->list); +kfree (m_node); + +mutex_unlock (&c_node->mem_lock); +return ret; +} + +static void ipp_free_event (struct drm_pending_event *event) +{ +kfree (event); +} + +static int ipp_get_event (struct drm_device *drm_dev, +struct drm_file *file, +struct drm_exynos_ipp_cmd_node *c_node, +struct drm_exynos_ipp_queue_buf *qbuf) +{ +struct drm_exynos_ipp_send_event *e; +unsigned long flags; + +DRM_DEBUG_KMS ("%s:ops_id[%d]buf_id[%d]\n" , __func__, + qbuf->ops_id, qbuf->buf_id); + + e =kzalloc (sizeof (*e),GFP_KERNEL ); + +if (!e) { +DRM_ERROR ("failed to allocate event.\n" ); +spin_lock_irqsave (&drm_dev->event_lock, flags); + file->event_space +=sizeof (e->event); +spin_unlock_irqrestore (&drm_dev->event_lock, flags); +return -ENOMEM ; + } + +/* make event */ + e->event.base.type =DRM_EXYNOS_IPP_EVENT ; + e->event.base.length =sizeof (e->event); + e->event.user_data = qbuf->user_data; + e->event.prop_id = qbuf->prop_id; + e->event.buf_id[EXYNOS_DRM_OPS_DST ] = qbuf->buf_id; + e->base.event = &e->event.base; + e->base.file_priv = file; + e->base.destroy = ipp_free_event; +list_add_tail (&e->base.link, &c_node->event_list); + +return 0 ; +} + +static void ipp_put_event (struct drm_exynos_ipp_cmd_node *c_node, +struct drm_exynos_ipp_queue_buf *qbuf) +{ +struct drm_exynos_ipp_send_event *e, *te; +int count =0 ; + +if (list_empty (&c_node->event_list)) { +DRM_DEBUG_KMS ("%s:event_list is empty.\n" , __func__); +return ; + } + +list_for_each_entry_safe (e, te, &c_node->event_list, base.link) { +DRM_DEBUG_KMS ("%s:count[%d]e[0x%x]\n" , + __func__, count++, (int )e); + +if (!qbuf) { +/* delete list */ +list_del (&e->base.link); +kfree (e); + }else if (e->event.buf_id[EXYNOS_DRM_OPS_DST ] + == qbuf->buf_id) { +/* delete list */ +list_del (&e->base.link); +kfree (e); +return ; + } + } + +return ; +} + +void ipp_handle_cmd_work (struct device *dev, +struct exynos_drm_ippdrv *ippdrv, +struct drm_exynos_ipp_cmd_work *cmd_work, +struct drm_exynos_ipp_cmd_node *c_node) +{ +struct ipp_context *ctx =get_ipp_context (dev); + + cmd_work->ippdrv = ippdrv; + cmd_work->c_node = c_node; +queue_work (ctx->cmd_workq, (struct work_struct *)cmd_work); +} + +int exynos_drm_ipp_queue_buf (struct drm_device *drm_dev,void *data, +struct drm_file *file) +{ +struct drm_exynos_file_private *file_priv = file->driver_priv; +struct exynos_drm_ipp_private *priv = file_priv->ipp_priv; +struct device *dev = priv->dev; +struct ipp_context *ctx =get_ipp_context (dev); +struct drm_exynos_ipp_queue_buf *qbuf = data; +struct exynos_drm_ippdrv *ippdrv; +struct drm_exynos_ipp_property *property; +struct exynos_drm_ipp_ops *ops; +struct drm_exynos_ipp_cmd_node *c_node; +struct drm_exynos_ipp_mem_node *m_node, *tm_node; +int ret; + +DRM_DEBUG_KMS ("%s\n" , __func__); + +if (!qbuf) { +DRM_ERROR ("invalid buf parameter.\n" ); +return -EINVAL ; + } + + ippdrv =ipp_find_drv_node (qbuf->prop_id); + +if (!ippdrv) { +DRM_ERROR ("failed to get ipp driver.\n" ); +return -EFAULT ; + } + +if (qbuf->ops_id >=EXYNOS_DRM_OPS_MAX ) { +DRM_ERROR ("invalid ops parameter.\n" ); +return -EINVAL ; + } + + ops = ippdrv->ops[qbuf->ops_id]; +if (!ops) { +DRM_ERROR ("failed to get ops.\n" ); +return -EFAULT ; + } + +DRM_DEBUG_KMS ("%s:prop_id[%d]ops_id[%s]buf_id[%d]buf_type[%d]\n" , + __func__, qbuf->prop_id, qbuf->ops_id ?"dst" :"src" , + qbuf->buf_id, qbuf->buf_type); + +/* find command node */ + c_node =ipp_find_id (&ctx->prop_idr, &ctx->prop_lock, + qbuf->prop_id); +if (!c_node) { +DRM_ERROR ("failed to get command node.\n" ); +return -EFAULT ; + } + +/* get property */ + property = &c_node->property; +if (!property) { +DRM_ERROR ("invalid property parameter.\n" ); +return -EINVAL ; + } + +/* buffer control */ +switch (qbuf->buf_type) { +case IPP_BUF_ENQUEUE : +/* get memory node */ + m_node =ipp_get_mem_node (drm_dev, file, c_node, qbuf); +if (!m_node) { +DRM_ERROR ("failed to get m_node.\n" ); +return -EINVAL ; + } +
drivers/gpu/drm/exynos/exynos_drm_ipp.c
Quoted 10 lines
drivers/gpu/drm/exynos/exynos_drm_ipp.c new file +10
-0+if (qbuf->ops_id ==EXYNOS_DRM_OPS_DST ) { +/* get event */ + ret =ipp_get_event (drm_dev, file, c_node, qbuf); +if (ret) { +DRM_ERROR ("failed to get event.\n" ); + goto err_clean_node; + } + +if (c_node->state !=IPP_STATE_START ) { + DRM_DEBUG_KMS("%s:bypass for invalid
state.\n"
Quoted 16 lines
drivers/gpu/drm/exynos/exynos_drm_ipp.c new file +16
-0+ , __func__); +break ; + } + +if (!ipp_check_mem_list (c_node)) { +DRM_DEBUG_KMS ("%s:empty memory.\n" + , __func__); +break ; + } + +/* +* If set source, destination buffer and enable pm +* m2m operations need start operations in queue +*/ +if (property->cmd ==IPP_CMD_M2M ) { + struct drm_exynos_ipp_cmd_work *cmd_work =
drivers/gpu/drm/exynos/exynos_drm_ipp.c
Quoted 10 lines
drivers/gpu/drm/exynos/exynos_drm_ipp.c new file +10
-0+ c_node->start_work; + + cmd_work->ctrl =IPP_CTRL_PLAY ; +ipp_handle_cmd_work (dev, ippdrv, cmd_work, + c_node); + }else { +if (ops->set_addr) { + ret = ops->set_addr(ippdrv->dev, + &m_node->buf_info, + m_node->buf_id,
qbuf->buf_type);
drivers/gpu/drm/exynos/exynos_drm_ipp.c
Quoted 3 lines
drivers/gpu/drm/exynos/exynos_drm_ipp.c new file +3
-0+if (ret) { + DRM_ERROR( + "failed to set
addr.\n");
Quoted 421 lines
drivers/gpu/drm/exynos/exynos_drm_ipp.c new file +421
-0+ goto err_clean_node; + } + } + } + } +break ; +case IPP_BUF_DEQUEUE : +mutex_lock (&c_node->cmd_lock); + +if (qbuf->ops_id ==EXYNOS_DRM_OPS_DST ) +ipp_put_event (c_node, qbuf); + +/* put memory node */ +if (!list_empty (&c_node->mem_list[qbuf->ops_id])) { +list_for_each_entry_safe (m_node, tm_node, + &c_node->mem_list[qbuf->ops_id], list) { +if (m_node->buf_id == qbuf->buf_id && + m_node->ops_id == qbuf->ops_id) { +/* put memory node */ +ipp_put_mem_node (drm_dev, + c_node, m_node); + } + } + } +mutex_unlock (&c_node->cmd_lock); +break ; +default : +DRM_ERROR ("invalid buffer control.\n" ); +return -EINVAL ; + } + +return 0 ; + +err_clean_node: +DRM_ERROR ("clean memory nodes.\n" ); + +if (!list_empty (&c_node->mem_list[qbuf->ops_id])) { +/* delete list */ +list_for_each_entry_safe (m_node, tm_node, + &c_node->mem_list[qbuf->ops_id], list) { +if (m_node->buf_id == qbuf->buf_id && + m_node->ops_id == qbuf->ops_id) +ipp_put_mem_node (drm_dev, c_node, m_node); + } + } + +return ret; +} +EXPORT_SYMBOL_GPL (exynos_drm_ipp_queue_buf); + +static bool exynos_drm_ipp_check_valid (struct device *dev, +enum drm_exynos_ipp_ctrl ctrl,enum drm_exynos_ipp_state state) +{ +DRM_DEBUG_KMS ("%s\n" , __func__); + +if (ctrl !=IPP_CTRL_PLAY ) { +if (pm_runtime_suspended (dev)) { +DRM_ERROR ("pm:runtime_suspended.\n" ); + goto err_status; + } + } + +switch (ctrl) { +case IPP_CTRL_PLAY : +if (state !=IPP_STATE_IDLE ) + goto err_status; +break ; +case IPP_CTRL_STOP : +if (state ==IPP_STATE_STOP ) + goto err_status; +break ; +case IPP_CTRL_PAUSE : +if (state !=IPP_STATE_START ) + goto err_status; +break ; +case IPP_CTRL_RESUME : +if (state !=IPP_STATE_STOP ) + goto err_status; +break ; +default : +DRM_ERROR ("invalid state.\n" ); + goto err_status; +break ; + } + +return true; + +err_status: +DRM_ERROR ("invalid status:ctrl[%d]state[%d]\n" , ctrl, state); +return false; +} + +int exynos_drm_ipp_cmd_ctrl (struct drm_device *drm_dev,void *data, +struct drm_file *file) +{ +struct drm_exynos_file_private *file_priv = file->driver_priv; +struct exynos_drm_ipp_private *priv = file_priv->ipp_priv; +struct exynos_drm_ippdrv *ippdrv =NULL ; +struct device *dev = priv->dev; +struct ipp_context *ctx =get_ipp_context (dev); +struct drm_exynos_ipp_cmd_ctrl *cmd_ctrl = data; +struct drm_exynos_ipp_cmd_work *cmd_work; +struct drm_exynos_ipp_cmd_node *c_node; +int ret =0 ; + +DRM_DEBUG_KMS ("%s\n" , __func__); + +if (!ctx) { +DRM_ERROR ("invalid context.\n" ); +return -EINVAL ; + } + +if (!cmd_ctrl) { +DRM_ERROR ("invalid control parameter.\n" ); +return -EINVAL ; + } + +DRM_DEBUG_KMS ("%s:ctrl[%d]prop_id[%d]\n" , __func__, + cmd_ctrl->ctrl, cmd_ctrl->prop_id); + + ippdrv =ipp_find_drv_node (cmd_ctrl->prop_id); + +if (!ippdrv) { +DRM_ERROR ("failed to get ipp driver.\n" ); +return -EINVAL ; + } + + c_node =ipp_find_id (&ctx->prop_idr, &ctx->prop_lock, + cmd_ctrl->prop_id); + +if (!c_node) { +DRM_ERROR ("invalid command node list.\n" ); +return -EINVAL ; + } + +if (!exynos_drm_ipp_check_valid (ippdrv->dev, cmd_ctrl->ctrl, + c_node->state)) { +DRM_ERROR ("invalid state.\n" ); +return -EINVAL ; + } + +switch (cmd_ctrl->ctrl) { +case IPP_CTRL_PLAY : +if (pm_runtime_suspended (ippdrv->dev)) +pm_runtime_get_sync (ippdrv->dev); + c_node->state =IPP_STATE_START ; + + cmd_work = c_node->start_work; + cmd_work->ctrl = cmd_ctrl->ctrl; +ipp_handle_cmd_work (dev, ippdrv, cmd_work, c_node); +break ; +case IPP_CTRL_STOP : +cancel_work_sync ((struct work_struct *)c_node->start_work); +cancel_work_sync ((struct work_struct *)c_node->event_work); + c_node->state =IPP_STATE_STOP ; + + cmd_work = c_node->stop_work; + cmd_work->ctrl = cmd_ctrl->ctrl; +ipp_handle_cmd_work (dev, ippdrv, cmd_work, c_node); + +if (!wait_for_completion_timeout (&c_node->stop_complete, +msecs_to_jiffies (200 ))) { +DRM_ERROR ("timeout stop:prop_id[%d]\n" , + c_node->property.prop_id); + } + + ippdrv->dedicated = false; +ipp_clean_cmd_node (c_node); + +if (list_empty (&ippdrv->cmd_list)) +pm_runtime_put_sync (ippdrv->dev); +break ; +case IPP_CTRL_PAUSE : +cancel_work_sync ((struct work_struct *)c_node->start_work); +cancel_work_sync ((struct work_struct *)c_node->event_work); + c_node->state =IPP_STATE_STOP ; + + cmd_work = c_node->stop_work; + cmd_work->ctrl = cmd_ctrl->ctrl; +ipp_handle_cmd_work (dev, ippdrv, cmd_work, c_node); + +if (!wait_for_completion_timeout (&c_node->stop_complete, +msecs_to_jiffies (200 ))) { +DRM_ERROR ("timeout stop:prop_id[%d]\n" , + c_node->property.prop_id); + } +break ; +case IPP_CTRL_RESUME : + c_node->state =IPP_STATE_START ; + + cmd_work = c_node->start_work; + cmd_work->ctrl = cmd_ctrl->ctrl; +ipp_handle_cmd_work (dev, ippdrv, cmd_work, c_node); +break ; +default : +/* ToDo: expand ctrl operation */ +DRM_ERROR ("could not support this state currently.\n" ); + goto err_clear; + } + +DRM_DEBUG_KMS ("%s:done ctrl[%d]prop_id[%d]\n" , __func__, + cmd_ctrl->ctrl, cmd_ctrl->prop_id); + +return 0 ; + +err_clear: +return ret; +} +EXPORT_SYMBOL_GPL (exynos_drm_ipp_cmd_ctrl); + +int exynos_drm_ippnb_register (struct notifier_block *nb) +{ +return blocking_notifier_chain_register ( + &exynos_drm_ippnb_list, nb); +} +EXPORT_SYMBOL_GPL (exynos_drm_ippnb_register); + +int exynos_drm_ippnb_unregister (struct notifier_block *nb) +{ +return blocking_notifier_chain_unregister ( + &exynos_drm_ippnb_list, nb); +} +EXPORT_SYMBOL_GPL (exynos_drm_ippnb_unregister); + +int exynos_drm_ippnb_send_event (unsigned long val,void *v) +{ +return blocking_notifier_call_chain ( + &exynos_drm_ippnb_list, val, v); +} +EXPORT_SYMBOL_GPL (exynos_drm_ippnb_send_event); + +static int ipp_set_property (struct exynos_drm_ippdrv *ippdrv, +struct drm_exynos_ipp_property *property) +{ +struct exynos_drm_ipp_ops *ops =NULL ; +int ret, i, swap =0 ; + +if (!property) { +DRM_ERROR ("invalid property parameter.\n" ); +return -EINVAL ; + } + +DRM_DEBUG_KMS ("%s:prop_id[%d]\n" , __func__, property->prop_id); + +/* reset h/w block */ +if (ippdrv->reset && + ippdrv->reset (ippdrv->dev)) { +DRM_ERROR ("failed to reset.\n" ); +return -EINVAL ; + } + +/* set source,destination operations */ +for_each_ipp_ops (i) { +/* ToDo: integrate property and config */ +struct drm_exynos_ipp_config *config = + &property->config[i]; + + ops = ippdrv->ops[i]; +if (!ops || !config) { +DRM_ERROR ("not support ops and config.\n" ); +return -EINVAL ; + } + +/* set format */ +if (ops->set_fmt) { + ret = ops->set_fmt (ippdrv->dev, config->fmt); +if (ret) { +DRM_ERROR ("not support format.\n" ); +return ret; + } + } + +/* set transform for rotation, flip */ +if (ops->set_transf) { + swap = ops->set_transf (ippdrv->dev, config->degree, + config->flip); +if (swap <0 ) { +DRM_ERROR ("not support tranf.\n" ); +return -EINVAL ; + } + } + +/* set size */ +if (ops->set_size) { + ret = ops->set_size (ippdrv->dev, swap, &config->pos, + &config->sz); +if (ret) { +DRM_ERROR ("not support size.\n" ); +return ret; + } + } + } + +return 0 ; +} + +static int ipp_start_property (struct exynos_drm_ippdrv *ippdrv, +struct drm_exynos_ipp_cmd_node *c_node) +{ +struct drm_exynos_ipp_mem_node *m_node; +struct drm_exynos_ipp_property *property = &c_node->property; +struct list_head *head; +int ret, i; + +DRM_DEBUG_KMS ("%s:prop_id[%d]\n" , __func__, property->prop_id); + +/* store command info in ippdrv */ + ippdrv->cmd = c_node; + +if (!ipp_check_mem_list (c_node)) { +DRM_DEBUG_KMS ("%s:empty memory.\n" , __func__); +return -ENOMEM ; + } + +/* set current property in ippdrv */ + ret =ipp_set_property (ippdrv, property); +if (ret) { +DRM_ERROR ("failed to set property.\n" ); + ippdrv->cmd =NULL ; +return ret; + } + +/* check command */ +switch (property->cmd) { +case IPP_CMD_M2M : +for_each_ipp_ops (i) { +/* source/destination memory list */ + head = &c_node->mem_list[i]; + +/* get first entry */ + m_node =list_first_entry (head, + struct drm_exynos_ipp_mem_node, list); +if (!m_node) { +DRM_ERROR ("failed to get node.\n" ); + ret = -EFAULT ; +return ret; + } + +DRM_DEBUG_KMS ("%s:m_node[0x%x]\n" , + __func__, (int )m_node); + +/* set memory node to ippdrv */ + ret =ipp_set_mem_node (ippdrv, c_node, m_node); +if (ret) { +DRM_ERROR ("failed to set m node.\n" ); +return ret; + } + } +break ; +case IPP_CMD_WB : +/* destination memory list */ + head = &c_node->mem_list[EXYNOS_DRM_OPS_DST ]; + +/* get list entry */ +list_for_each_entry (m_node, head, list) { +/* set memory node to ippdrv */ + ret =ipp_set_mem_node (ippdrv, c_node, m_node); +if (ret) { +DRM_ERROR ("failed to set m node.\n" ); +return ret; + } + } +break ; +case IPP_CMD_OUTPUT : +/* source memory list */ + head = &c_node->mem_list[EXYNOS_DRM_OPS_SRC ]; + +/* get list entry */ +list_for_each_entry (m_node, head, list) { +/* set memory node to ippdrv */ + ret =ipp_set_mem_node (ippdrv, c_node, m_node); +if (ret) { +DRM_ERROR ("failed to set m node.\n" ); +return ret; + } + } +break ; +default : +DRM_ERROR ("invalid operations.\n" ); +return -EINVAL ; + } + +DRM_DEBUG_KMS ("%s:cmd[%d]\n" , __func__, property->cmd); + +/* start operations */ +if (ippdrv->start) { + ret = ippdrv->start (ippdrv->dev, property->cmd); +if (ret) { +DRM_ERROR ("failed to start ops.\n" ); +return ret; + } + } + +return 0 ; +} + +static int ipp_stop_property (struct drm_device *drm_dev, +struct exynos_drm_ippdrv *ippdrv, +struct drm_exynos_ipp_cmd_node *c_node) +{ +struct drm_exynos_ipp_mem_node *m_node, *tm_node; +struct drm_exynos_ipp_property *property = &c_node->property; +struct list_head *head; +int ret, i; + +DRM_DEBUG_KMS ("%s:prop_id[%d]\n" , __func__, property->prop_id); + +/* put event */ +ipp_put_event (c_node,NULL ); + +/* check command */ +switch (property->cmd) { +case IPP_CMD_M2M : +for_each_ipp_ops (i) { +/* source/destination memory list */ + head = &c_node->mem_list[i]; + +if (list_empty (head)) { +DRM_DEBUG_KMS ("%s:mem_list is empty.\n" , + __func__); +break ;
drivers/gpu/drm/exynos/exynos_drm_ipp.c
Quoted 10 lines
drivers/gpu/drm/exynos/exynos_drm_ipp.c new file +10
-0+ } + +/* get list entry */ +list_for_each_entry_safe (m_node, tm_node, + head, list) { +/* put memory node */ + ret =ipp_put_mem_node (drm_dev, c_node, + m_node); +if (ret) { + DRM_ERROR("failed to put
m_node.\n");
Quoted 73 lines
drivers/gpu/drm/exynos/exynos_drm_ipp.c new file +73
-0+ goto err_clear; + } + } + } +break ; +case IPP_CMD_WB : +/* destination memory list */ + head = &c_node->mem_list[EXYNOS_DRM_OPS_DST ]; + +if (list_empty (head)) { +DRM_DEBUG_KMS ("%s:mem_list is empty.\n" , __func__); +break ; + } + +/* get list entry */ +list_for_each_entry_safe (m_node, tm_node, head, list) { +/* put memory node */ + ret =ipp_put_mem_node (drm_dev, c_node, m_node); +if (ret) { +DRM_ERROR ("failed to put m_node.\n" ); + goto err_clear; + } + } +break ; +case IPP_CMD_OUTPUT : +/* source memory list */ + head = &c_node->mem_list[EXYNOS_DRM_OPS_SRC ]; + +if (list_empty (head)) { +DRM_DEBUG_KMS ("%s:mem_list is empty.\n" , __func__); +break ; + } + +/* get list entry */ +list_for_each_entry_safe (m_node, tm_node, head, list) { +/* put memory node */ + ret =ipp_put_mem_node (drm_dev, c_node, m_node); +if (ret) { +DRM_ERROR ("failed to put m_node.\n" ); + goto err_clear; + } + } +break ; +default : +DRM_ERROR ("invalid operations.\n" ); + ret = -EINVAL ; + goto err_clear; + } + +err_clear: +/* stop operations */ +if (ippdrv->stop) + ippdrv->stop (ippdrv->dev, property->cmd); + +return 0 ; +} + +void ipp_sched_cmd (struct work_struct *work) +{ +struct drm_exynos_ipp_cmd_work *cmd_work = + (struct drm_exynos_ipp_cmd_work *)work; +struct exynos_drm_ippdrv *ippdrv; +struct drm_exynos_ipp_cmd_node *c_node; +struct drm_exynos_ipp_property *property; +int ret; + +DRM_DEBUG_KMS ("%s\n" , __func__); + + ippdrv = cmd_work->ippdrv; +if (!ippdrv) { +DRM_ERROR ("invalid ippdrv list.\n" ); +return ; + }
drivers/gpu/drm/exynos/exynos_drm_ipp.c line 1397
Quoted 10 lines
drivers/gpu/drm/exynos/exynos_drm_ipp.c new file +10
-0+ + c_node = cmd_work->c_node; +if (!c_node) { +DRM_ERROR ("invalid command node list.\n" ); +return ; + } + +mutex_lock (&c_node->cmd_lock); + +/* get property */
Useless comment.
drivers/gpu/drm/exynos/exynos_drm_ipp.c line 1408
Quoted 11 lines
drivers/gpu/drm/exynos/exynos_drm_ipp.c new file +11
-0+ property = &c_node->property; +if (!property) { +DRM_ERROR ("failed to get property:prop_id[%d]\n" , + c_node->property.prop_id); + goto err_unlock; + } + +switch (cmd_work->ctrl) { +case IPP_CTRL_PLAY : +case IPP_CTRL_RESUME : +/* start property */
Useless comment.
drivers/gpu/drm/exynos/exynos_drm_ipp.c line 1416
Quoted 8 lines
drivers/gpu/drm/exynos/exynos_drm_ipp.c new file +8
-0+ ret =ipp_start_property (ippdrv, c_node); +if (ret) { +DRM_ERROR ("failed to start property:prop_id[%d]\n" , + c_node->property.prop_id); + goto err_unlock; + } + +if (property->cmd ==IPP_CMD_M2M ) {
Leave comment to why to do this if cmd is IPP_CMD_M2M.
drivers/gpu/drm/exynos/exynos_drm_ipp.c
Quoted 2 lines
drivers/gpu/drm/exynos/exynos_drm_ipp.c new file +2
-0+if (!wait_for_completion_timeout + (&c_node->start_complete,
msecs_to_jiffies(200))) {
Quoted 64 lines
drivers/gpu/drm/exynos/exynos_drm_ipp.c new file +64
-0+DRM_ERROR ("timeout event:prop_id[%d]\n" , + c_node->property.prop_id); + goto err_unlock; + } + } +break ; +case IPP_CTRL_STOP : +case IPP_CTRL_PAUSE : + ret =ipp_stop_property (ippdrv->drm_dev, ippdrv, + c_node); +if (ret) { +DRM_ERROR ("failed to stop property.\n" ); + goto err_unlock; + } + +complete (&c_node->stop_complete); +break ; +default : +DRM_ERROR ("unknown control type\n" ); +break ; + } + +DRM_DEBUG_KMS ("%s:ctrl[%d] done.\n" , __func__, cmd_work->ctrl); + +err_unlock: +mutex_unlock (&c_node->cmd_lock); +} + +static int ipp_send_event (struct exynos_drm_ippdrv *ippdrv, +struct drm_exynos_ipp_cmd_node *c_node,int *buf_id) +{ +struct drm_device *drm_dev = ippdrv->drm_dev; +struct drm_exynos_ipp_property *property = &c_node->property; +struct drm_exynos_ipp_mem_node *m_node; +struct drm_exynos_ipp_queue_buf qbuf; +struct drm_exynos_ipp_send_event *e; +struct list_head *head; +struct timeval now; +unsigned long flags; +u32 tbuf_id[EXYNOS_DRM_OPS_MAX ] = {0 , }; +int ret, i; + +for_each_ipp_ops (i) +DRM_DEBUG_KMS ("%s:%s buf_id[%d]\n" , __func__, + i ?"dst" :"src" , buf_id[i]); + +if (!drm_dev) { +DRM_ERROR ("failed to get drm_dev.\n" ); +return -EINVAL ; + } + +if (!property) { +DRM_ERROR ("failed to get property.\n" ); +return -EINVAL ; + } + +if (list_empty (&c_node->event_list)) { +DRM_DEBUG_KMS ("%s:event list is empty.\n" , __func__); +return 0 ; + } + +if (!ipp_check_mem_list (c_node)) { +DRM_DEBUG_KMS ("%s:empty memory.\n" , __func__); +return 0 ;
drivers/gpu/drm/exynos/exynos_drm_ipp.c line 1492
Quoted 10 lines
drivers/gpu/drm/exynos/exynos_drm_ipp.c new file +10
-0+ } + +/* check command */ +switch (property->cmd) { +case IPP_CMD_M2M : +for_each_ipp_ops (i) { +/* source/destination memory list */ + head = &c_node->mem_list[i]; + +/* get first entry */
Useless comment.
drivers/gpu/drm/exynos/exynos_drm_ipp.c line 1504
Quoted 12 lines
drivers/gpu/drm/exynos/exynos_drm_ipp.c new file +12
-0+ m_node =list_first_entry (head, + struct drm_exynos_ipp_mem_node, list); +if (!m_node) { +DRM_ERROR ("empty memory node.\n" ); +return -ENOMEM ; + } + + tbuf_id[i] = m_node->buf_id; +DRM_DEBUG_KMS ("%s:%s buf_id[%d]\n" , __func__, + i ?"dst" :"src" , tbuf_id[i]); + +/* put memory node */
Useless comment. why this memory node should be putted?
Quoted 45 lines
drivers/gpu/drm/exynos/exynos_drm_ipp.c new file +45
-0+ ret =ipp_put_mem_node (drm_dev, c_node, m_node); +if (ret) +DRM_ERROR ("failed to put m_node.\n" ); + } +break ; +case IPP_CMD_WB : +/* clear buf for finding */ +memset (&qbuf,0x0 ,sizeof (qbuf)); + qbuf.ops_id =EXYNOS_DRM_OPS_DST ; + qbuf.buf_id = buf_id[EXYNOS_DRM_OPS_DST ]; + +/* get memory node entry */ + m_node =ipp_find_mem_node (c_node, &qbuf); +if (!m_node) { +DRM_ERROR ("empty memory node.\n" ); +return -ENOMEM ; + } + + tbuf_id[EXYNOS_DRM_OPS_DST ] = m_node->buf_id; + +/* put memory node */ + ret =ipp_put_mem_node (drm_dev, c_node, m_node); +if (ret) +DRM_ERROR ("failed to put m_node.\n" ); +break ; +case IPP_CMD_OUTPUT : +/* source memory list */ + head = &c_node->mem_list[EXYNOS_DRM_OPS_SRC ]; + +/* get first entry */ + m_node =list_first_entry (head, + struct drm_exynos_ipp_mem_node, list); +if (!m_node) { +DRM_ERROR ("empty memory node.\n" ); +return -ENOMEM ; + } + + tbuf_id[EXYNOS_DRM_OPS_SRC ] = m_node->buf_id; + +/* put memory node */ + ret =ipp_put_mem_node (drm_dev, c_node, m_node); +if (ret) +DRM_ERROR ("failed to put m_node.\n" ); +break ; +default :
drivers/gpu/drm/exynos/exynos_drm_ipp.c line 1559
Quoted 10 lines
drivers/gpu/drm/exynos/exynos_drm_ipp.c new file +10
-0+DRM_ERROR ("invalid operations.\n" ); +return -EINVAL ; + } + +/* ToDo: Fix buffer id */ +if (tbuf_id[EXYNOS_DRM_OPS_DST ] != buf_id[EXYNOS_DRM_OPS_DST ]) +DRM_ERROR ("failed to match buf_id[%d %d]prop_id[%d]\n" , + tbuf_id[1 ], buf_id[1 ], property->prop_id); + +/* get first event entry */
Levae comment to why it should get first event to do what?
Quoted 51 lines
drivers/gpu/drm/exynos/exynos_drm_ipp.c new file +27
-0+ e =list_first_entry (&c_node->event_list, + struct drm_exynos_ipp_send_event, base.link); + +if (!e) { +DRM_ERROR ("empty event.\n" ); +return -EINVAL ; + } + +do_gettimeofday (&now); +DRM_DEBUG_KMS ("%s:tv_sec[%ld]tv_usec[%ld]\n" + , __func__, now.tv_sec, now.tv_usec); + e->event.tv_sec = now.tv_sec; + e->event.tv_usec = now.tv_usec; + e->event.prop_id = property->prop_id; + +/* set buffer id about source destination */ +for_each_ipp_ops (i) + e->event.buf_id[i] = tbuf_id[i]; +/* ToDo: compare index. If needed */ + +spin_lock_irqsave (&drm_dev->event_lock, flags); +list_move_tail (&e->base.link, &e->base.file_priv->event_list); +wake_up_interruptible (&e->base.file_priv->event_wait); +spin_unlock_irqrestore (&drm_dev->event_lock, flags); + + DRM_DEBUG_KMS("%s:done cmd[%d]prop_id[%d]buf_id[%d]\n", __func__, + property->cmd, property->prop_id,tbuf_id[EXYNOS_DRM_OPS_DST]);
drivers/gpu/drm/exynos/exynos_drm_ipp.c new file +23
-0+ +return 0 ; +} + +void ipp_sched_event (struct work_struct *work) +{ +struct drm_exynos_ipp_event_work *event_work = + (struct drm_exynos_ipp_event_work *)work; +struct exynos_drm_ippdrv *ippdrv; +struct drm_exynos_ipp_cmd_node *c_node; +int ret; + +if (!event_work) { +DRM_ERROR ("failed to get event_work.\n" ); +return ; + } + +DRM_DEBUG_KMS ("%s:buf_id[%d]\n" , __func__, + event_work->buf_id[EXYNOS_DRM_OPS_DST ]); + + ippdrv = event_work->ippdrv; +if (!ippdrv) { +DRM_ERROR ("failed to get ipp driver.\n" );
drivers/gpu/drm/exynos/exynos_drm_ipp.c line 1619
Quoted 10 lines
drivers/gpu/drm/exynos/exynos_drm_ipp.c new file +10
-0+return ; + } + + c_node = ippdrv->cmd; +if (!c_node) { +DRM_ERROR ("failed to get command node.\n" ); +return ; + } + +if (c_node->state !=IPP_STATE_START ) {
Leave comment to why and then how.
Quoted 24 lines
drivers/gpu/drm/exynos/exynos_drm_ipp.c new file +21
-0+DRM_DEBUG_KMS ("%s:bypass state[%d]prop_id[%d]\n" , + __func__, c_node->state, c_node->property.prop_id); + goto err_completion; + } + +mutex_lock (&c_node->event_lock); + + ret =ipp_send_event (ippdrv, c_node, event_work->buf_id); +if (ret) { +DRM_ERROR ("failed to send event.\n" ); + goto err_completion; + } + +err_completion: +if (c_node->property.cmd ==IPP_CMD_M2M ) +complete (&c_node->start_complete); + +mutex_unlock (&c_node->event_lock); +} + +static int ipp_subdrv_probe(struct drm_device *drm_dev, struct device*dev)
drivers/gpu/drm/exynos/exynos_drm_ipp.c new file +2
-0+{ +struct ipp_context *ctx =get_ipp_context (dev);
drivers/gpu/drm/exynos/exynos_drm_ipp.c line 1652
Quoted 10 lines
drivers/gpu/drm/exynos/exynos_drm_ipp.c new file +10
-0+struct exynos_drm_ippdrv *ippdrv; +int ret, count =0 ; + +DRM_DEBUG_KMS ("%s\n" , __func__); + +/* get ipp driver entry */ +list_for_each_entry (ippdrv, &exynos_drm_ippdrv_list, drv_list) { + ippdrv->drm_dev = drm_dev; + +/* create ipp id */
Useless comment.
drivers/gpu/drm/exynos/exynos_drm_ipp.c line 1657
Quoted 5 lines
drivers/gpu/drm/exynos/exynos_drm_ipp.c new file +5
-0+ ret =ipp_create_id (&ctx->ipp_idr, &ctx->ipp_lock, ippdrv, + &ippdrv->ipp_id); +if (ret) { +DRM_ERROR ("failed to create id.\n" ); + goto err_idr;
At this point, a new idr isn't created.
Quoted 39 lines
drivers/gpu/drm/exynos/exynos_drm_ipp.c new file +3
-0+ } + + DRM_DEBUG_KMS("%s:count[%d]ippdrv[0x%x]ipp_id[%d]\n",
__func__,drivers/gpu/drm/exynos/exynos_drm_ipp.c new file +29
-0+ count++, (int)ippdrv, ippdrv->ipp_id); + +if (ippdrv->ipp_id ==0 ) { +DRM_ERROR ("failed to get ipp_id[%d]\n" , + ippdrv->ipp_id); + goto err_idr; + } + +/* store parent device for node */ + ippdrv->parent_dev = dev; + +/* store event work queue and handler */ + ippdrv->event_workq = ctx->event_workq; + ippdrv->sched_event = ipp_sched_event; +INIT_LIST_HEAD (&ippdrv->cmd_list); + } + +return 0 ; + +err_idr: +idr_remove_all (&ctx->ipp_idr); +idr_remove_all (&ctx->prop_idr); +idr_destroy (&ctx->ipp_idr); +idr_destroy (&ctx->prop_idr); + +return ret; +} + +static void ipp_subdrv_remove(struct drm_device *drm_dev, struct device*dev)
drivers/gpu/drm/exynos/exynos_drm_ipp.c new file +5
-0+{ +struct exynos_drm_ippdrv *ippdrv; + +DRM_DEBUG_KMS ("%s\n" , __func__); +
drivers/gpu/drm/exynos/exynos_drm_ipp.c
Quoted 10 lines
drivers/gpu/drm/exynos/exynos_drm_ipp.c new file +10
-0+/* get ipp driver entry */ +list_for_each_entry (ippdrv, &exynos_drm_ippdrv_list, drv_list) { + ippdrv->drm_dev =NULL ; +exynos_drm_ippdrv_unregister (ippdrv); + } + +/* ToDo: free notifier callback list if needed */ +} + +static int ipp_subdrv_open(struct drm_device *drm_dev, struct device
*dev,
Quoted 42 lines
drivers/gpu/drm/exynos/exynos_drm_ipp.c new file +25
-0+ struct drm_file *file) +{ +struct drm_exynos_file_private *file_priv = file->driver_priv; +struct exynos_drm_ipp_private *priv; + +DRM_DEBUG_KMS ("%s\n" , __func__); + +/* ToDo: multi device open */ + + priv =kzalloc (sizeof (*priv),GFP_KERNEL ); +if (!priv) { +DRM_ERROR ("failed to allocate priv.\n" ); +return -ENOMEM ; + } + priv->dev = dev; + file_priv->ipp_priv = priv; + +INIT_LIST_HEAD (&priv->event_list); + +DRM_DEBUG_KMS ("%s:done priv[0x%x]\n" , __func__, (int )priv); + +return 0 ; +} + +static void ipp_subdrv_close(struct drm_device *drm_dev, struct device*dev,
drivers/gpu/drm/exynos/exynos_drm_ipp.c new file +16
-0+ struct drm_file *file) +{ +struct drm_exynos_file_private *file_priv = file->driver_priv; +struct exynos_drm_ipp_private *priv = file_priv->ipp_priv; +struct exynos_drm_ippdrv *ippdrv =NULL ; +struct drm_exynos_ipp_cmd_node *c_node, *tc_node; +int count =0 ; + +DRM_DEBUG_KMS ("%s:for priv[0x%x]\n" , __func__, (int )priv); + +if (list_empty (&exynos_drm_ippdrv_list)) { +DRM_DEBUG_KMS ("%s:ippdrv_list is empty.\n" , __func__); + goto err_clear; + } + +list_for_each_entry (ippdrv, &exynos_drm_ippdrv_list, drv_list) {
drivers/gpu/drm/exynos/exynos_drm_ipp.c line 1755
Quoted 10 lines
drivers/gpu/drm/exynos/exynos_drm_ipp.c new file +10
-0+if (list_empty (&ippdrv->cmd_list)) +continue ; + +list_for_each_entry_safe (c_node, tc_node, + &ippdrv->cmd_list, list) { +DRM_DEBUG_KMS ("%s:count[%d]ippdrv[0x%x]\n" , + __func__, count++, (int )ippdrv); + +if (c_node->priv == priv) { +if (c_node->state ==IPP_STATE_START ) {
Leave comments to why IPP_STATE_START should be checked and then relevant driver should be stopped at here.
drivers/gpu/drm/exynos/exynos_drm_ipp.c line 1762
Quoted 7 lines
drivers/gpu/drm/exynos/exynos_drm_ipp.c new file +7
-0+ipp_stop_property (drm_dev, ippdrv, + c_node); + c_node->state =IPP_STATE_STOP ; + } + + ippdrv->dedicated = false; +ipp_clean_cmd_node (c_node);
Leave comments to why c_node should be cleaned at here.
drivers/gpu/drm/exynos/exynos_drm_ipp.c
Quoted 1 line
drivers/gpu/drm/exynos/exynos_drm_ipp.c new file +1
-0+if (list_empty (&ippdrv->cmd_list))
Also. such as 'each driver has no any command to process so the ipp driver should be off.'
Quoted 16 lines
drivers/gpu/drm/exynos/exynos_drm_ipp.c new file +16
-0+pm_runtime_put_sync (ippdrv->dev); + } + } + } + +err_clear: +kfree (priv); + +return ; +} + +static int __devinit ipp_probe (struct platform_device *pdev) +{ +struct device *dev = &pdev->dev; +struct ipp_context *ctx; +struct exynos_drm_subdrv *subdrv;
drivers/gpu/drm/exynos/exynos_drm_ipp.c line 1789
Quoted 10 lines
drivers/gpu/drm/exynos/exynos_drm_ipp.c new file +10
-0+int ret = -EINVAL ; + + ctx =kzalloc (sizeof (*ctx),GFP_KERNEL ); +if (!ctx) +return -ENOMEM ; + +DRM_DEBUG_KMS ("%s\n" , __func__); + +mutex_init (&ctx->ipp_lock); +mutex_init (&ctx->prop_lock);
Leave a blank line.
drivers/gpu/drm/exynos/exynos_drm_ipp.c line 1790
Quoted 1 line
drivers/gpu/drm/exynos/exynos_drm_ipp.c new file +1
-0+/* init ipp driver idr */
Useless comment.
drivers/gpu/drm/exynos/exynos_drm_ipp.c line 1792
Quoted 2 lines
drivers/gpu/drm/exynos/exynos_drm_ipp.c new file +2
-0+idr_init (&ctx->ipp_idr); +idr_init (&ctx->prop_idr);
Leave a blank line.
drivers/gpu/drm/exynos/exynos_drm_ipp.c line 1793
Quoted 1 line
drivers/gpu/drm/exynos/exynos_drm_ipp.c new file +1
-0+/* create single thread for ipp event */
Useless comment. Leave how this event_workq is used instead.
drivers/gpu/drm/exynos/exynos_drm_ipp.c line 1801
Quoted 8 lines
drivers/gpu/drm/exynos/exynos_drm_ipp.c new file +8
-0+ ctx->event_workq =create_singlethread_workqueue ("ipp_event" ); +if (!ctx->event_workq) { +dev_err (dev,"failed to create event workqueue\n" ); + ret = -EINVAL ; + goto err_clear; + } + +/* create single thread for ipp command */
Useless comment. Leave how this event_workq is used instead.
Quoted 6 lines
drivers/gpu/drm/exynos/exynos_drm_ipp.c new file +6
-0+ ctx->cmd_workq =create_singlethread_workqueue ("ipp_cmd" ); +if (!ctx->cmd_workq) { +dev_err (dev,"failed to create cmd workqueue\n" ); + ret = -EINVAL ; + goto err_event_workq; + }
drivers/gpu/drm/exynos/exynos_drm_ipp.c line 1817
Quoted 10 lines
drivers/gpu/drm/exynos/exynos_drm_ipp.c new file +10
-0+ +/* set sub driver informations */ + subdrv = &ctx->subdrv; + subdrv->dev = dev; + subdrv->probe = ipp_subdrv_probe; + subdrv->remove = ipp_subdrv_remove; + subdrv->open = ipp_subdrv_open; + subdrv->close = ipp_subdrv_close; + +/* set driver data */
Useless comment.
drivers/gpu/drm/exynos/exynos_drm_ipp.c line 1818
Quoted 1 line
drivers/gpu/drm/exynos/exynos_drm_ipp.c new file +1
-0+platform_set_drvdata (pdev, ctx);
Useless comment.
Quoted 272 lines
drivers/gpu/drm/exynos/exynos_drm_ipp.c new file +115
-0+ +/* register sub driver */ + ret =exynos_drm_subdrv_register (subdrv); +if (ret <0 ) { +DRM_ERROR ("failed to register drm ipp device.\n" ); + goto err_cmd_workq; + } + +dev_info (&pdev->dev,"drm ipp registered successfully.\n" ); + +return 0 ; + +err_cmd_workq: +destroy_workqueue (ctx->cmd_workq); +err_event_workq: +destroy_workqueue (ctx->event_workq); +err_clear: +kfree (ctx); + +return ret; +} + +static int __devexit ipp_remove(struct platform_device *pdev) +{ +struct ipp_context *ctx =platform_get_drvdata (pdev); + +DRM_DEBUG_KMS ("%s\n" , __func__); + +/* unregister sub driver */ +exynos_drm_subdrv_unregister (&ctx->subdrv); + +/* remove,destroy ipp idr */ +idr_remove_all (&ctx->ipp_idr); +idr_remove_all (&ctx->prop_idr); +idr_destroy (&ctx->ipp_idr); +idr_destroy (&ctx->prop_idr); + +/* destroy command, event work queue */ +destroy_workqueue (ctx->cmd_workq); +destroy_workqueue (ctx->event_workq); + +kfree (ctx); + +return 0 ; +} + +static int ipp_power_ctrl (struct ipp_context *ctx,bool enable) +{ +/* ToDo: Need to implement power and sysmmu ctrl. */ +DRM_DEBUG_KMS ("%s:enable[%d]\n" , __func__, enable); + +return 0 ; +} + +#ifdef CONFIG_PM_SLEEP +static int ipp_suspend (struct device *dev) +{ +struct ipp_context *ctx =get_ipp_context (dev); + +DRM_DEBUG_KMS ("%s\n" , __func__); + +if (pm_runtime_suspended (dev)) +return 0 ; + +return ipp_power_ctrl (ctx, false); +} + +static int ipp_resume (struct device *dev) +{ +struct ipp_context *ctx =get_ipp_context (dev); + +DRM_DEBUG_KMS ("%s\n" , __func__); + +if (!pm_runtime_suspended (dev)) +return ipp_power_ctrl (ctx, true); + +return 0 ; +} +#endif + +#ifdef CONFIG_PM_RUNTIME +static int ipp_runtime_suspend (struct device *dev) +{ +struct ipp_context *ctx =get_ipp_context (dev); + +DRM_DEBUG_KMS ("%s\n" , __func__); + +return ipp_power_ctrl (ctx, false); +} + +static int ipp_runtime_resume (struct device *dev) +{ +struct ipp_context *ctx =get_ipp_context (dev); + +DRM_DEBUG_KMS ("%s\n" , __func__); + +return ipp_power_ctrl (ctx, true); +} +#endif + +static const struct dev_pm_ops ipp_pm_ops = { + SET_SYSTEM_SLEEP_PM_OPS(ipp_suspend, ipp_resume) +SET_RUNTIME_PM_OPS (ipp_runtime_suspend, ipp_runtime_resume,NULL ) +}; + +struct platform_driver ipp_driver = { + .probe = ipp_probe, + .remove =__devexit_p (ipp_remove), + .driver = { + .name ="exynos-drm-ipp" , + .owner =THIS_MODULE , + .pm = &ipp_pm_ops, + }, +}; +drivers/gpu/drm/exynos/exynos_drm_ipp.h new file +9
-0@@ -0,0 +1,268 @@ +/* +* Copyright (c) 2012 Samsung Electronics Co., Ltd. +* +* Authors: +* Eunchul Kim <[email protected]> +* Jinyoung Jeon <[email protected]> +* Sangmin Lee <[email protected]> +* +* Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ */drivers/gpu/drm/exynos/exynos_drm_ipp.h new file +113
-0+ +#ifndef _EXYNOS_DRM_IPP_H_ +#define _EXYNOS_DRM_IPP_H_ + +#define for_each_ipp_ops (pos) \ + for (pos = 0; pos < EXYNOS_DRM_OPS_MAX; pos++) +#define for_each_ipp_planar (pos) \ + for (pos = 0; pos < EXYNOS_DRM_PLANAR_MAX; pos++) + +#define IPP_GET_LCD_WIDTH _IOR('F', 302, int) +#define IPP_GET_LCD_HEIGHT _IOR('F', 303, int) +#define IPP_SET_WRITEBACK _IOW('F', 304, u32) + +/* definition of state */ +enum drm_exynos_ipp_state { +IPP_STATE_IDLE , +IPP_STATE_START , +IPP_STATE_STOP , +}; + +/* +* A structure of command work information. +* @work: work structure. +* @ippdrv: current work ippdrv. +* @c_node: command node information. +* @ctrl: command control. +*/ +struct drm_exynos_ipp_cmd_work { +struct work_struct work; +struct exynos_drm_ippdrv *ippdrv; +struct drm_exynos_ipp_cmd_node *c_node; +enum drm_exynos_ipp_ctrl ctrl; +}; + +/* +* A structure of command node. +* +* @priv: IPP private infomation. +* @list: list head to command queue information. +* @event_list: list head of event. +* @mem_list: list head to source,destination memory queue information. +* @cmd_lock: lock for synchronization of access to ioctl. +* @mem_lock: lock for synchronization of access to memory nodes. +* @event_lock: lock for synchronization of access to scheduled event. +* @start_complete: completion of start of command. +* @stop_complete: completion of stop of command. +* @property: property information. +* @start_work: start command work structure. +* @stop_work: stop command work structure. +* @event_work: event work structure. +* @state: state of command node. +*/ +struct drm_exynos_ipp_cmd_node { +struct exynos_drm_ipp_private *priv; +struct list_head list; +struct list_head event_list; +struct list_head mem_list[EXYNOS_DRM_OPS_MAX ]; +struct mutex cmd_lock; +struct mutex mem_lock; +struct mutex event_lock; +struct completion start_complete; +struct completion stop_complete; +struct drm_exynos_ipp_property property; +struct drm_exynos_ipp_cmd_work *start_work; +struct drm_exynos_ipp_cmd_work *stop_work; +struct drm_exynos_ipp_event_work *event_work; +enum drm_exynos_ipp_state state; +}; + +/* +* A structure of buffer information. +* +* @file: handle of file. +* @gem_handle: Y, Cb, Cr each gem handle. +* @base: Y, Cb, Cr each planar address. +*/ +struct drm_exynos_ipp_buf_info { +struct drm_file *file; +unsigned int gem_handle[EXYNOS_DRM_PLANAR_MAX ]; +dma_addr_t base[EXYNOS_DRM_PLANAR_MAX ]; +}; + +/* +* A structure of wb setting infomation. +* +* @enable: enable flag for wb. +* @refresh: HZ of the refresh rate. +*/ +struct drm_exynos_ipp_set_wb { +__u32 enable; +__u32 refresh; +}; + +/* +* A structure of event work information. +* +* @work: work structure. +* @ippdrv: current work ippdrv. +* @buf_id: id of src, dst buffer. +*/ +struct drm_exynos_ipp_event_work { +struct work_struct work; +struct exynos_drm_ippdrv *ippdrv; +u32 buf_id[EXYNOS_DRM_OPS_MAX ]; +}; + +/* +* A structure of source,destination operations. +* +* @set_fmt: set format of image. +* @set_transf: set transform(rotations, flip). +* @set_size: set size of region. +* @set_addr: set address for dma.
drivers/gpu/drm/exynos/exynos_drm_ipp.h
Quoted 10 lines
drivers/gpu/drm/exynos/exynos_drm_ipp.h new file +10
-0+*/ +struct exynos_drm_ipp_ops { +int (*set_fmt)(struct device *dev,u32 fmt); +int (*set_transf)(struct device *dev, +enum drm_exynos_degree degree, +enum drm_exynos_flip flip); +int (*set_size)(struct device *dev,int swap, +struct drm_exynos_pos *pos,struct drm_exynos_sz *sz); +int (*set_addr)(struct device *dev, + struct drm_exynos_ipp_buf_info *buf_info, u32
buf_id,
Quoted 37 lines
drivers/gpu/drm/exynos/exynos_drm_ipp.h new file +37
-0+ enum drm_exynos_ipp_buf_type buf_type); +}; + +/* +* A structure of ipp driver. +* +* @drv_list: list head for registed sub driver information. +* @parent_dev: parent device information. +* @dev: platform device. +* @drm_dev: drm device. +* @ipp_id: id of ipp driver. +* @dedicated: dedicated ipp device. +* @ops: source, destination operations. +* @event_workq: event work queue. +* @cmd: current command information. +* @cmd_list: list head for command information. +* @prop_list: property informations of current ipp driver. +* @check_property: check property about format, size, buffer. +* @reset: reset ipp block. +* @start: ipp each device start. +* @stop: ipp each device stop. +* @sched_event: work schedule handler. +*/ +struct exynos_drm_ippdrv { +struct list_head drv_list; +struct device *parent_dev; +struct device *dev; +struct drm_device *drm_dev; +u32 ipp_id; +bool dedicated; +struct exynos_drm_ipp_ops *ops[EXYNOS_DRM_OPS_MAX ]; +struct workqueue_struct *event_workq; +struct drm_exynos_ipp_cmd_node *cmd; +struct list_head cmd_list; +struct drm_exynos_ipp_prop_list *prop_list; + + int (*check_property)(struct device *dev,
drivers/gpu/drm/exynos/exynos_drm_ipp.h
Quoted 10 lines
drivers/gpu/drm/exynos/exynos_drm_ipp.h new file +10
-0+ struct drm_exynos_ipp_property *property); +int (*reset)(struct device *dev); +int (*start)(struct device *dev,enum drm_exynos_ipp_cmd cmd); +void (*stop)(struct device *dev,enum drm_exynos_ipp_cmd cmd); +void (*sched_event)(struct work_struct *work); +}; + +#ifdef CONFIG_DRM_EXYNOS_IPP +extern int exynos_drm_ippdrv_register (struct exynos_drm_ippdrv *ippdrv); +extern int exynos_drm_ippdrv_unregister(struct exynos_drm_ippdrv
*ippdrv);
drivers/gpu/drm/exynos/exynos_drm_ipp.h
Quoted 10 lines
+extern int exynos_drm_ipp_get_property(struct
drm_device*drm_dev, void *data,drivers/gpu/drm/exynos/exynos_drm_ipp.h new file +2
-0+ struct drm_file *file); +extern int exynos_drm_ipp_set_property(struct drm_device *drm_dev, void*data,
drivers/gpu/drm/exynos/exynos_drm_ipp.h new file +2
-0+ struct drm_file *file); +extern int exynos_drm_ipp_queue_buf(struct drm_device *drm_dev, void*data,
drivers/gpu/drm/exynos/exynos_drm_ipp.h new file +2
-0+ struct drm_file *file); +extern int exynos_drm_ipp_cmd_ctrl(struct drm_device *drm_dev, void
*data,
Quoted 255 lines
drivers/gpu/drm/exynos/exynos_drm_ipp.h new file +9
-0+ struct drm_file *file); +extern int exynos_drm_ippnb_register (struct notifier_block *nb); +extern int exynos_drm_ippnb_unregister (struct notifier_block *nb); +extern int exynos_drm_ippnb_send_event (unsigned long val,void *v); +extern void ipp_sched_cmd (struct work_struct *work); +extern void ipp_sched_event (struct work_struct *work); + +#else +static inline int exynos_drm_ippdrv_register(struct exynos_drm_ippdrv*ippdrv)
drivers/gpu/drm/exynos/exynos_drm_ipp.h new file +5
-0+{ +return -ENODEV ; +} + +static inline int exynos_drm_ippdrv_unregister(struct exynos_drm_ippdrv*ippdrv)
drivers/gpu/drm/exynos/exynos_drm_ipp.h new file +50
-0+{ +return -ENODEV ; +} + +static inline int exynos_drm_ipp_get_property (struct drm_device *drm_dev, +void *data, +struct drm_file *file_priv) +{ +return -ENOTTY ; +} + +static inline int exynos_drm_ipp_set_property (struct drm_device *drm_dev, +void *data, +struct drm_file *file_priv) +{ +return -ENOTTY ; +} + +static inline int exynos_drm_ipp_queue_buf (struct drm_device *drm_dev, +void *data, +struct drm_file *file) +{ +return -ENOTTY ; +} + +static inline int exynos_drm_ipp_cmd_ctrl (struct drm_device *drm_dev, +void *data, +struct drm_file *file) +{ +return -ENOTTY ; +} + +static inline int exynos_drm_ippnb_register (struct notifier_block *nb) +{ +return -ENODEV ; +} + +static inline int exynos_drm_ippnb_unregister (struct notifier_block *nb) +{ +return -ENODEV ; +} + +static inline int exynos_drm_ippnb_send_event (unsigned long val,void *v) +{ +return -ENOTTY ; +} +#endif + +#endif /* _EXYNOS_DRM_IPP_H_ */ +include/uapi/drm/exynos_drm.h +169
-0@@ -154,6 +154,169 @@ struct drm_exynos_g2d_exec {__u64 async; }; +enum drm_exynos_ops_id { +EXYNOS_DRM_OPS_SRC , +EXYNOS_DRM_OPS_DST , +EXYNOS_DRM_OPS_MAX , +}; + +struct drm_exynos_sz { +__u32 hsize; +__u32 vsize; +}; + +struct drm_exynos_pos { +__u32 x; +__u32 y; +__u32 w; +__u32 h; +}; + +enum drm_exynos_flip { +EXYNOS_DRM_FLIP_NONE = (0 <<0 ), +EXYNOS_DRM_FLIP_VERTICAL = (1 <<0 ), +EXYNOS_DRM_FLIP_HORIZONTAL = (1 <<1 ), +}; + +enum drm_exynos_degree { +EXYNOS_DRM_DEGREE_0 , +EXYNOS_DRM_DEGREE_90 , +EXYNOS_DRM_DEGREE_180 , +EXYNOS_DRM_DEGREE_270 , +}; + +enum drm_exynos_planer { +EXYNOS_DRM_PLANAR_Y , +EXYNOS_DRM_PLANAR_CB , +EXYNOS_DRM_PLANAR_CR , +EXYNOS_DRM_PLANAR_MAX , +}; + +/** +* A structure for ipp supported property list. +* +* @version: version of this structure. +* @ipp_id: id of ipp driver. +* @count: count of ipp driver. +* @writeback: flag of writeback supporting. +* @flip: flag of flip supporting. +* @degree: flag of degree information. +* @csc: flag of csc supporting. +* @crop: flag of crop supporting. +* @scale: flag of scale supporting. +* @refresh_min: min hz of refresh. +* @refresh_max: max hz of refresh. +* @crop_min: crop min resolution. +* @crop_max: crop max resolution. +* @scale_min: scale min resolution. +* @scale_max: scale max resolution. +*/ +struct drm_exynos_ipp_prop_list { +__u32 version; +__u32 ipp_id; +__u32 count; +__u32 writeback; +__u32 flip; +__u32 degree; +__u32 csc; +__u32 crop; +__u32 scale; +__u32 refresh_min; +__u32 refresh_max; +__u32 reserved; +struct drm_exynos_sz crop_min; +struct drm_exynos_sz crop_max; +struct drm_exynos_sz scale_min; +struct drm_exynos_sz scale_max; +}; + +/** +* A structure for ipp config. +* +* @ops_id: property of operation directions. +* @flip: property of mirror, flip. +* @degree: property of rotation degree. +* @fmt: property of image format. +* @sz: property of image size. +* @pos: property of image position(src-cropped,dst-scaler). +*/ +struct drm_exynos_ipp_config { +enum drm_exynos_ops_id ops_id; +enum drm_exynos_flip flip; +enum drm_exynos_degree degree; +__u32 fmt; +struct drm_exynos_sz sz; +struct drm_exynos_pos pos; +}; + +enum drm_exynos_ipp_cmd { +IPP_CMD_NONE , +IPP_CMD_M2M , +IPP_CMD_WB , +IPP_CMD_OUTPUT , +IPP_CMD_MAX , +}; + +/** +* A structure for ipp property. +* +* @config: source, destination config. +* @cmd: definition of command. +* @ipp_id: id of ipp driver. +* @prop_id: id of property. +*/ +struct drm_exynos_ipp_property { +struct drm_exynos_ipp_config config[EXYNOS_DRM_OPS_MAX ]; +enum drm_exynos_ipp_cmd cmd; +__u32 ipp_id; +__u32 prop_id; +__u32 reserved; +}; + +enum drm_exynos_ipp_buf_type { +IPP_BUF_ENQUEUE , +IPP_BUF_DEQUEUE , +}; + +/** +* A structure for ipp buffer operations. +* +* @ops_id: operation directions. +* @buf_type: definition of buffer. +* @prop_id: id of property. +* @buf_id: id of buffer. +* @handle: Y, Cb, Cr each planar handle. +* @user_data: user data. +*/ +struct drm_exynos_ipp_queue_buf { +enum drm_exynos_ops_id ops_id; +enum drm_exynos_ipp_buf_type buf_type; +__u32 prop_id; +__u32 buf_id; +__u32 handle[EXYNOS_DRM_PLANAR_MAX ]; +__u32 reserved; +__u64 user_data; +}; + +enum drm_exynos_ipp_ctrl { +IPP_CTRL_PLAY , +IPP_CTRL_STOP , +IPP_CTRL_PAUSE , +IPP_CTRL_RESUME , +IPP_CTRL_MAX , +}; + +/** +* A structure for ipp start/stop operations. +* +* @prop_id: id of property. +* @ctrl: definition of control. +*/ +struct drm_exynos_ipp_cmd_ctrl { +__u32 prop_id; +enum drm_exynos_ipp_ctrl ctrl; +}; +#define DRM_EXYNOS_GEM_CREATE 0x00#define DRM_EXYNOS_GEM_MAP_OFFSET 0x01#define DRM_EXYNOS_GEM_MMAP 0x02@@ -166,6 +329,12 @@ struct drm_exynos_g2d_exec {#define DRM_EXYNOS_G2D_SET_CMDLIST 0x21#define DRM_EXYNOS_G2D_EXEC 0x22 +/* IPP - Image Post Processing */ +#define DRM_EXYNOS_IPP_GET_PROPERTY 0x30 +#define DRM_EXYNOS_IPP_SET_PROPERTY 0x31 +#define DRM_EXYNOS_IPP_QUEUE_BUF 0x32 +#define DRM_EXYNOS_IPP_CMD_CTRL 0x33 +#define DRM_IOCTL_EXYNOS_GEM_CREATE DRM_IOWR(DRM_COMMAND_BASE + \ DRM_EXYNOS_GEM_CREATE, struct drm_exynos_gem_create)
include/uapi/drm/exynos_drm.h struct drm_exynos_g2d_exec { · line 363
Quoted 7 lines
include/uapi/drm/exynos_drm.h +2
-0@@ -188,8 +357,18 @@ struct drm_exynos_g2d_exec {#define DRM_IOCTL_EXYNOS_G2D_EXEC DRM_IOWR(DRM_COMMAND_BASE + \ DRM_EXYNOS_G2D_EXEC, struct drm_exynos_g2d_exec) +#define DRM_IOCTL_EXYNOS_IPP_GET_PROPERTY DRM_IOWR(DRM_COMMAND_BASE + \ +DRM_EXYNOS_IPP_GET_PROPERTY , struct
drm_exynos_ipp_prop_list)
include/uapi/drm/exynos_drm.h struct drm_exynos_g2d_exec { · line 367
Quoted 4 lines
include/uapi/drm/exynos_drm.h +3
-0+#define DRM_IOCTL_EXYNOS_IPP_SET_PROPERTY DRM_IOWR(DRM_COMMAND_BASE + \ + DRM_EXYNOS_IPP_SET_PROPERTY, struct drm_exynos_ipp_property) +#define DRM_IOCTL_EXYNOS_IPP_QUEUE_BUF DRM_IOWR(DRM_COMMAND_BASE +
\
include/uapi/drm/exynos_drm.h struct drm_exynos_g2d_exec { · line 369
Quoted 2 lines
include/uapi/drm/exynos_drm.h +2
-0+ DRM_EXYNOS_IPP_QUEUE_BUF, struct drm_exynos_ipp_queue_buf) +#define DRM_IOCTL_EXYNOS_IPP_CMD_CTRL
DRM_IOWR(DRM_COMMAND_BASE +
Quoted 26 lines
include/uapi/drm/exynos_drm.h +13
-1\ + DRM_EXYNOS_IPP_CMD_CTRL, struct drm_exynos_ipp_cmd_ctrl) +/* EXYNOS specific events */ #define DRM_EXYNOS_G2D_EVENT 0x80000000 +#define DRM_EXYNOS_IPP_EVENT 0x80000001struct drm_exynos_g2d_event {struct drm_event base;@@ -200,4 +379,14 @@ struct drm_exynos_g2d_event { __u32 reserved; }; +struct drm_exynos_ipp_event { +struct drm_event base; +__u64 user_data; +__u32 tv_sec; +__u32 tv_usec; +__u32 prop_id; +__u32 reserved; +__u32 buf_id[EXYNOS_DRM_OPS_MAX ]; +}; +#endif /* _UAPI_EXYNOS_DRM_H_ */ --1.7.0.4
Re: [RFC 1/4] drm/exynos: add ipp subsystem
Dear Inki Dae
Sorry. I was too late. I have some issue about another part. Thank's for comments.
I make some comments and checked IPP routine for comment out. almost finished. so, I can sent RFC v2 until this week.
I added little comment of your comments. please check that.
Thank's
BR
Eunchul KIm.
Quoted 1,578 lines · Inki Dae
Enchul, let's add comments enough first. Other guys couldn't afford to review your patch if you don't provide comments enough because they should analyze your patch set spending their efforts. And please rebase them to be based on exynos-drm-next.
Below is a little bit comments. Please, describe your codes as much as possible.
Thanks,
Inki DaeQuoted 73 lines
-----Original Message-----
From: Eunchul Kim [mailto:[email protected]]
Sent: Monday, October 29, 2012 10:11 PM
To: [email protected]; [email protected]
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Subject: [RFC 1/4] drm/exynos: add ipp subsystemIPP stand for Image Post Processing and supports image scaler/rotator /crop/flip/csc(color space conversion) and input/output DMA operations using ipp drivers.
also supports writeback and display output operations.
ipp driver include FIMC, Rotator, GSC, SC, so on.
and ipp is integration device driver for each hardware.Signed-off-by Eunchul Kim <[email protected]>Signed-off-by Jinyoung Jeon <[email protected]>--- drivers/gpu/drm/exynos/Kconfig | 6 + drivers/gpu/drm/exynos/Makefile | 1 + drivers/gpu/drm/exynos/exynos_drm_drv.c | 24 + drivers/gpu/drm/exynos/exynos_drm_drv.h | 7 + drivers/gpu/drm/exynos/exynos_drm_ipp.c | 1933 +++++++++++++++++++++++++++++++ drivers/gpu/drm/exynos/exynos_drm_ipp.h | 268 +++++ include/uapi/drm/exynos_drm.h | 189 +++ 7 files changed, 2428 insertions(+), 0 deletions(-)create mode 100644
drivers/gpu/drm/exynos/exynos_drm_ipp.ccreate mode 100644drivers/gpu/drm/exynos/exynos_drm_ipp.hdrivers/gpu/drm/exynos/Kconfig +6
-0@@ -39,3 +39,9 @@ config DRM_EXYNOS_G2D depends on DRM_EXYNOS && !VIDEO_SAMSUNG_S5P_G2D help Choose this option if you want to use Exynos G2D for DRM. + +config DRM_EXYNOS_IPP + bool "Exynos DRM IPP" + depends on DRM_EXYNOS + help + Choose this option if you want to use IPP feature for DRM.drivers/gpu/drm/exynos/Makefile +1
-0@@ -15,5 +15,6 @@ exynosdrm-$(CONFIG_DRM_EXYNOS_HDMI) += exynos_hdmi.o exynos_mixer.o \ exynos_drm_hdmi.o exynosdrm-$(CONFIG_DRM_EXYNOS_VIDI) += exynos_drm_vidi.o exynosdrm-$(CONFIG_DRM_EXYNOS_G2D) += exynos_drm_g2d.o +exynosdrm-$(CONFIG_DRM_EXYNOS_IPP) += exynos_drm_ipp.oobj-$(CONFIG_DRM_EXYNOS) += exynosdrm.odrivers/gpu/drm/exynos/exynos_drm_drv.c +1
-0@@ -40,6 +40,7 @@#include "exynos_drm_vidi.h" #include "exynos_drm_dmabuf.h" #include "exynos_drm_g2d.h" +#include "exynos_drm_ipp.h" #define DRIVER_NAME "exynos"#define DRIVER_DESC "Samsung SoC DRM"drivers/gpu/drm/exynos/exynos_drm_drv.c static struct drm_ioctl_desc exynos_ioctls[] = { · line 233
Quoted 1 line
drivers/gpu/drm/exynos/exynos_drm_drv.c +0
-0@@ -232,6 +233,14 @@ static struct drm_ioctl_desc exynos_ioctls[] = { exynos_g2d_set_cmdlist_ioctl, DRM_UNLOCKED |
DRM_AUTH),drivers/gpu/drm/exynos/exynos_drm_drv.c static struct drm_ioctl_desc exynos_ioctls[] = {
Quoted 4 lines
drivers/gpu/drm/exynos/exynos_drm_drv.c +2
-0DRM_IOCTL_DEF_DRV (EXYNOS_G2D_EXEC , exynos_g2d_exec_ioctl,DRM_UNLOCKED |DRM_AUTH ), + DRM_IOCTL_DEF_DRV(EXYNOS_IPP_GET_PROPERTY, + exynos_drm_ipp_get_property, DRM_UNLOCKED |
DRM_AUTH),drivers/gpu/drm/exynos/exynos_drm_drv.c static struct drm_ioctl_desc exynos_ioctls[] = { · line 239
Quoted 2 lines
drivers/gpu/drm/exynos/exynos_drm_drv.c +2
-0+ DRM_IOCTL_DEF_DRV(EXYNOS_IPP_SET_PROPERTY, + exynos_drm_ipp_set_property, DRM_UNLOCKED |
DRM_AUTH),Quoted 312 lines
drivers/gpu/drm/exynos/exynos_drm_drv.c +19
-0+DRM_IOCTL_DEF_DRV (EXYNOS_IPP_QUEUE_BUF , + exynos_drm_ipp_queue_buf,DRM_UNLOCKED |DRM_AUTH ), +DRM_IOCTL_DEF_DRV (EXYNOS_IPP_CMD_CTRL , + exynos_drm_ipp_cmd_ctrl, DRM_UNLOCKED | DRM_AUTH), }; static const struct file_operations exynos_drm_driver_fops = {@@ -346,6 +355,12 @@ static int __init exynos_drm_init(void) goto out_g2d;#endif +#ifdef CONFIG_DRM_EXYNOS_IPP + ret =platform_driver_register (&ipp_driver); +if (ret <0 ) + goto out_ipp; +#endif + ret =platform_driver_register (&exynos_drm_platform_driver);if (ret <0 ) goto out_drm;@@ -363,6 +378,11 @@ out:platform_driver_unregister (&exynos_drm_platform_driver); out_drm: +#ifdef CONFIG_DRM_EXYNOS_IPP +platform_driver_unregister (&ipp_driver); +out_ipp: +#endif +#ifdef CONFIG_DRM_EXYNOS_G2D platform_driver_unregister (&g2d_driver); out_g2d:@@ -399,6 +419,10 @@ static void __exit exynos_drm_exit(void)platform_driver_unregister (&exynos_drm_platform_driver); +#ifdef CONFIG_DRM_EXYNOS_IPP +platform_driver_unregister (&ipp_driver); +#endif +#ifdef CONFIG_DRM_EXYNOS_G2D platform_driver_unregister (&g2d_driver);#endif drivers/gpu/drm/exynos/exynos_drm_drv.h +7
-0@@ -235,8 +235,14 @@ struct exynos_drm_g2d_private {unsigned int gem_nr; }; +struct exynos_drm_ipp_private { +struct device *dev; +struct list_head event_list; +}; +struct drm_exynos_file_private {struct exynos_drm_g2d_private *g2d_priv; +struct exynos_drm_ipp_private *ipp_priv; };/* @@ -335,4 +341,5 @@ extern struct platform_driver mixer_driver;extern struct platform_driver exynos_drm_common_hdmi_driver;extern struct platform_driver vidi_driver;extern struct platform_driver g2d_driver; +extern struct platform_driver ipp_driver;#endif drivers/gpu/drm/exynos/exynos_drm_ipp.c new file +8
-0@@ -0,0 +1,1933 @@ +/* +* Copyright (C) 2012 Samsung Electronics Co.Ltd +* Authors: +* Eunchul Kim <[email protected]> +* Jinyoung Jeon <[email protected]> +* Sangmin Lee <[email protected]> +* +* This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; either version 2 of the License, or (at your
+ * option) any later version.
+ *
+ */drivers/gpu/drm/exynos/exynos_drm_ipp.c new file +21
-0+#include <linux/kernel.h> +#include <linux/module.h> +#include <linux/platform_device.h> +#include <linux/clk.h> +#include <linux/pm_runtime.h> +#include <plat/map-base.h> + +#include <drm/drmP.h> +#include <drm/exynos_drm.h> +#include "exynos_drm_drv.h" +#include "exynos_drm_gem.h" +#include "exynos_drm_ipp.h" + +/* +* IPP is stand for Image Post Processing and +* supports image scaler/rotator and input/output DMA operations. +* using FIMC, GSC, Rotator, so on. +* IPP is integration device driver of same attribute h/w +*/ + +#define get_ipp_context (dev)platform_get_drvdata(to_platform_device(dev))
drivers/gpu/drm/exynos/exynos_drm_ipp.c new file +74
-0+ +/* +* A structure of event. +* +* @base: base of event. +* @event: ipp event. +*/ +struct drm_exynos_ipp_send_event { +struct drm_pending_event base; +struct drm_exynos_ipp_event event; +}; + +/* +* A structure of memory node. +* +* @list: list head to memory queue information. +* @ops_id: id of operations. +* @prop_id: id of property. +* @buf_id: id of buffer. +* @buf_info: gem objects and dma address, size. +*/ +struct drm_exynos_ipp_mem_node { +struct list_head list; +enum drm_exynos_ops_id ops_id; +u32 prop_id; +u32 buf_id; +struct drm_exynos_ipp_buf_info buf_info; +}; + +/* +* A structure of ipp context. +* +* @subdrv: prepare initialization using subdrv. +* @ipp_lock: lock for synchronization of access to ipp_idr. +* @prop_lock: lock for synchronization of access to prop_idr. +* @ipp_idr: ipp driver idr. +* @prop_idr: property idr. +* @event_workq: event work queue. +* @cmd_workq: command work queue. +*/ +struct ipp_context { +struct exynos_drm_subdrv subdrv; +struct mutex ipp_lock; +struct mutex prop_lock; +struct idr ipp_idr; +struct idr prop_idr; +struct workqueue_struct *event_workq; +struct workqueue_struct *cmd_workq; +}; + +static LIST_HEAD (exynos_drm_ippdrv_list); +static BLOCKING_NOTIFIER_HEAD (exynos_drm_ippnb_list); + +int exynos_drm_ippdrv_register (struct exynos_drm_ippdrv *ippdrv) +{ +DRM_DEBUG_KMS ("%s\n" , __func__); + +list_add_tail (&ippdrv->drv_list, &exynos_drm_ippdrv_list); + +return 0 ; +} +EXPORT_SYMBOL_GPL (exynos_drm_ippdrv_register); + +int exynos_drm_ippdrv_unregister (struct exynos_drm_ippdrv *ippdrv) +{ +DRM_DEBUG_KMS ("%s\n" , __func__); + +list_del (&ippdrv->drv_list); + +return 0 ; +} +EXPORT_SYMBOL_GPL (exynos_drm_ippdrv_unregister); + +static int ipp_create_id(struct idr *id_idr, struct mutex *lock, void*obj,
drivers/gpu/drm/exynos/exynos_drm_ipp.c new file +81
-0+ u32 *idp) +{ +int ret = -EINVAL ; + +DRM_DEBUG_KMS ("%s\n" , __func__); + +again: +/* ensure there is space available to allocate a handle */ +if (idr_pre_get (id_idr,GFP_KERNEL ) ==0 ) +return -ENOMEM ; + +/* do the allocation under our mutexlock */ +mutex_lock (lock); + ret =idr_get_new_above (id_idr, obj,1 , (int *)idp); +mutex_unlock (lock); +if (ret == -EAGAIN ) + goto again; + +return ret; +} + +static void *ipp_find_id (struct idr *id_idr,struct mutex *lock,u32 id) +{ +void *obj; + +DRM_DEBUG_KMS ("%s:id[%d]\n" , __func__, id); + +mutex_lock (lock); + +/* find object using handle */ + obj =idr_find (id_idr, id); +if (obj ==NULL ) { +mutex_unlock (lock); +return NULL ; + } + +mutex_unlock (lock); + +return obj; +} + +static struct exynos_drm_ippdrv *ipp_find_driver (struct ipp_context *ctx, +struct drm_exynos_ipp_property *property) +{ +struct exynos_drm_ippdrv *ippdrv; +u32 ipp_id = property->ipp_id; + +DRM_DEBUG_KMS ("%s:ipp_id[%d]\n" , __func__, ipp_id); + +if (ipp_id) { +/* find ipp driver */ + ippdrv =ipp_find_id (&ctx->ipp_idr, &ctx->ipp_lock, + ipp_id); +if (!ippdrv) { +DRM_ERROR ("not found ipp%d driver.\n" , ipp_id); + goto err_null; + } + +/* check dedicated state */ +if (ippdrv->dedicated) { +DRM_ERROR ("used choose device.\n" ); + goto err_null; + } + +if (property->cmd !=IPP_CMD_M2M + && !pm_runtime_suspended (ippdrv->dev)) { +DRM_ERROR ("can't run dedicatedly.\n" ); + goto err_null; + } + +/* check property */ +if (ippdrv->check_property && + ippdrv->check_property (ippdrv->dev, property)) { +DRM_ERROR ("not support property.\n" ); + goto err_null; + } + +return ippdrv; + }else { +/* get ipp driver entry */ + list_for_each_entry(ippdrv, &exynos_drm_ippdrv_list,
drv_list) {drivers/gpu/drm/exynos/exynos_drm_ipp.c new file +41
-0+/* check dedicated state */ +if (ippdrv->dedicated) +continue ; + +if (property->cmd !=IPP_CMD_M2M + && !pm_runtime_suspended (ippdrv->dev)) { +DRM_DEBUG_KMS ("%s:can't run dedicatedly.\n" , + __func__); +continue ; + } + +/* check property */ +if (ippdrv->check_property && + ippdrv->check_property (ippdrv->dev, property)) { +DRM_DEBUG_KMS ("%s:not support property.\n" , + __func__); +continue ; + } + +return ippdrv; + } + +DRM_ERROR ("not support ipp driver operations.\n" ); + } + +return ERR_PTR (-ENODEV ); + +err_null: +return NULL ; +} + +static struct exynos_drm_ippdrv *ipp_find_drv_node (u32 prop_id) +{ +struct exynos_drm_ippdrv *ippdrv; +struct drm_exynos_ipp_cmd_node *c_node; +int count =0 ; + +DRM_DEBUG_KMS ("%s:prop_id[%d]\n" , __func__, prop_id); + +if (list_empty (&exynos_drm_ippdrv_list)) { + DRM_DEBUG_KMS("%s:ippdrv_list is empty.\n",drivers/gpu/drm/exynos/exynos_drm_ipp.c
Quoted 10 lines
drivers/gpu/drm/exynos/exynos_drm_ipp.c new file +10
-0+ __func__); +return NULL ; + } + +list_for_each_entry (ippdrv, &exynos_drm_ippdrv_list, drv_list) { +DRM_DEBUG_KMS ("%s:count[%d]ippdrv[0x%x]\n" , + __func__, count++, (int )ippdrv); + +if (!list_empty (&ippdrv->cmd_list)) { +list_for_each_entry (c_node, &ippdrv->cmd_list, list){
Quoted 99 lines
drivers/gpu/drm/exynos/exynos_drm_ipp.c new file +36
-0+if (c_node->property.prop_id == prop_id) +return ippdrv; + } + } + } + +return NULL ; +} + +int exynos_drm_ipp_get_property (struct drm_device *drm_dev,void *data, +struct drm_file *file) +{ +struct drm_exynos_file_private *file_priv = file->driver_priv; +struct exynos_drm_ipp_private *priv = file_priv->ipp_priv; +struct device *dev = priv->dev; +struct ipp_context *ctx =get_ipp_context (dev); +struct drm_exynos_ipp_prop_list *prop_list = data; +struct exynos_drm_ippdrv *ippdrv; +int count =0 ; + +DRM_DEBUG_KMS ("%s\n" , __func__); + +if (!ctx) { +DRM_ERROR ("invalid context.\n" ); +return -EINVAL ; + } + +if (!prop_list) { +DRM_ERROR ("invalid property parameter.\n" ); +return -EINVAL ; + } + +DRM_DEBUG_KMS ("%s:ipp_id[%d]\n" , __func__, prop_list->ipp_id); + +if (prop_list->ipp_id ==0 ) { + list_for_each_entry(ippdrv, &exynos_drm_ippdrv_list,
drv_list)drivers/gpu/drm/exynos/exynos_drm_ipp.c new file +62
-0+ count++; + prop_list->count = count; + }else { + ippdrv =ipp_find_id (&ctx->ipp_idr, &ctx->ipp_lock, + prop_list->ipp_id); + +if (!ippdrv) { +DRM_ERROR ("not found ipp%d driver.\n" , + prop_list->ipp_id); +return -EINVAL ; + } + + prop_list = ippdrv->prop_list; + } + +return 0 ; +} +EXPORT_SYMBOL_GPL (exynos_drm_ipp_get_property); + +int exynos_drm_ipp_set_property (struct drm_device *drm_dev,void *data, +struct drm_file *file) +{ +struct drm_exynos_file_private *file_priv = file->driver_priv; +struct exynos_drm_ipp_private *priv = file_priv->ipp_priv; +struct device *dev = priv->dev; +struct ipp_context *ctx =get_ipp_context (dev); +struct drm_exynos_ipp_property *property = data; +struct exynos_drm_ippdrv *ippdrv; +struct drm_exynos_ipp_cmd_node *c_node; +struct drm_exynos_ipp_config *config; +struct drm_exynos_pos *pos; +struct drm_exynos_sz *sz; +int ret, i; + +DRM_DEBUG_KMS ("%s\n" , __func__); + +if (!ctx) { +DRM_ERROR ("invalid context.\n" ); +return -EINVAL ; + } + +if (!property) { +DRM_ERROR ("invalid property parameter.\n" ); +return -EINVAL ; + } + +for_each_ipp_ops (i) { + config = &property->config[i]; + pos = &config->pos; + sz = &config->sz; + +DRM_DEBUG_KMS ("%s:prop_id[%d]ops[%s]fmt[0x%x]\n" , + __func__, property->prop_id, + i ?"dst" :"src" , config->fmt); + +DRM_DEBUG_KMS ("%s:pos[%d %d %d %d]sz[%d %d]f[%d]r[%d]\n" , + __func__, pos->x, pos->y, pos->w, pos->h, + sz->hsize, sz->vsize, config->flip, config->degree); + } + +if (property->prop_id) { + ippdrv =ipp_find_drv_node (property->prop_id);drivers/gpu/drm/exynos/exynos_drm_ipp.c
Quoted 10 lines
drivers/gpu/drm/exynos/exynos_drm_ipp.c new file +10
-0+if (!ippdrv) { +DRM_ERROR ("failed to get ipp driver.\n" ); +return -EINVAL ; + } + +list_for_each_entry (c_node, &ippdrv->cmd_list, list) { +if ((c_node->property.prop_id == + property->prop_id) && + (c_node->state ==IPP_STATE_STOP )) { + DRM_DEBUG_KMS("%s:foundcmd[%d]ippdrv[0x%x]\n",
drivers/gpu/drm/exynos/exynos_drm_ipp.c
Quoted 1 line
drivers/gpu/drm/exynos/exynos_drm_ipp.c new file +1
-0+ __func__, property->cmd,(int)ippdrv);
Quoted 275 lines
drivers/gpu/drm/exynos/exynos_drm_ipp.c new file +153
-0+ + c_node->property = *property; +return 0 ; + } + } + +DRM_ERROR ("failed to search property.\n" ); +return -EINVAL ; + } + +/* find ipp driver using ipp id */ + ippdrv =ipp_find_driver (ctx, property); +if (IS_ERR_OR_NULL (ippdrv)) { +DRM_ERROR ("failed to get ipp driver.\n" ); +return -EINVAL ; + } + +/* allocate command node */ + c_node =kzalloc (sizeof (*c_node),GFP_KERNEL ); +if (!c_node) { +DRM_ERROR ("failed to allocate map node.\n" ); +return -ENOMEM ; + } + +/* create property id */ + ret =ipp_create_id (&ctx->prop_idr, &ctx->prop_lock, c_node, + &property->prop_id); +if (ret) { +DRM_ERROR ("failed to create id.\n" ); + goto err_clear; + } + +DRM_DEBUG_KMS ("%s:created prop_id[%d]cmd[%d]ippdrv[0x%x]\n" , + __func__, property->prop_id, property->cmd, (int )ippdrv); + +/* stored property information and ippdrv in private data */ + c_node->priv = priv; + c_node->property = *property; + c_node->state =IPP_STATE_IDLE ; + + c_node->start_work =kzalloc (sizeof (*c_node->start_work), +GFP_KERNEL ); +if (!c_node->start_work) { +DRM_ERROR ("failed to alloc start_work.\n" ); + ret = -ENOMEM ; + goto err_clear; + } + +INIT_WORK ((struct work_struct *)c_node->start_work, + ipp_sched_cmd); + + c_node->stop_work =kzalloc (sizeof (*c_node->stop_work), +GFP_KERNEL ); +if (!c_node->stop_work) { +DRM_ERROR ("failed to alloc stop_work.\n" ); + ret = -ENOMEM ; + goto err_free_start; + } + +INIT_WORK ((struct work_struct *)c_node->stop_work, + ipp_sched_cmd); + + c_node->event_work =kzalloc (sizeof (*c_node->event_work), +GFP_KERNEL ); +if (!c_node->event_work) { +DRM_ERROR ("failed to alloc event_work.\n" ); + ret = -ENOMEM ; + goto err_free_stop; + } + +INIT_WORK ((struct work_struct *)c_node->event_work, + ipp_sched_event); + +/* init ioctl lock */ +mutex_init (&c_node->cmd_lock); +mutex_init (&c_node->mem_lock); +mutex_init (&c_node->event_lock); +init_completion (&c_node->start_complete); +init_completion (&c_node->stop_complete); + +for_each_ipp_ops (i) +INIT_LIST_HEAD (&c_node->mem_list[i]); + +INIT_LIST_HEAD (&c_node->event_list); +list_splice_init (&priv->event_list, &c_node->event_list); +list_add_tail (&c_node->list, &ippdrv->cmd_list); + +/* make dedicated state without m2m */ +if (property->cmd !=IPP_CMD_M2M ) + ippdrv->dedicated = true; + +return 0 ; + +err_free_stop: +kfree (c_node->stop_work); +err_free_start: +kfree (c_node->start_work); +err_clear: +kfree (c_node); +return ret; +} +EXPORT_SYMBOL_GPL (exynos_drm_ipp_set_property); + +static struct drm_exynos_ipp_mem_node + *ipp_find_mem_node (struct drm_exynos_ipp_cmd_node *c_node, +struct drm_exynos_ipp_queue_buf *qbuf) +{ +struct drm_exynos_ipp_mem_node *m_node; +struct list_head *head; +int count =0 ; + +DRM_DEBUG_KMS ("%s:buf_id[%d]\n" , __func__, qbuf->buf_id); + +/* source/destination memory list */ + head = &c_node->mem_list[qbuf->ops_id]; + +/* find memory node entry */ +list_for_each_entry (m_node, head, list) { +DRM_DEBUG_KMS ("%s:count[%d]m_node[0x%x]\n" , + __func__, count++, (int )m_node); + +/* compare buffer id */ +if (m_node->buf_id == qbuf->buf_id) +return m_node; + } + +return NULL ; +} + +static int ipp_check_mem_list (struct drm_exynos_ipp_cmd_node *c_node) +{ +struct drm_exynos_ipp_property *property = &c_node->property; +struct drm_exynos_ipp_mem_node *m_node; +struct list_head *head; +int ret, i, count[EXYNOS_DRM_OPS_MAX ] = {0 , }; + +DRM_DEBUG_KMS ("%s\n" , __func__); + +mutex_lock (&c_node->mem_lock); + +for_each_ipp_ops (i) { +/* source/destination memory list */ + head = &c_node->mem_list[i]; + +if (list_empty (head)) { +DRM_DEBUG_KMS ("%s:%s memory empty.\n" , __func__, + i ?"dst" :"src" ); +continue ; + } + +/* find memory node entry */ +list_for_each_entry (m_node, head, list) { + DRM_DEBUG_KMS("%s:%s,count[%d]m_node[0x%x]\n",
__func__,drivers/gpu/drm/exynos/exynos_drm_ipp.c new file +121
-0+ i ? "dst" : "src", count[i], (int)m_node); + count[i]++; + } + } + +DRM_DEBUG_KMS ("%s:min[%d]max[%d]\n" , __func__, +min (count[EXYNOS_DRM_OPS_SRC ], count[EXYNOS_DRM_OPS_DST ]), +max (count[EXYNOS_DRM_OPS_SRC ], count[EXYNOS_DRM_OPS_DST ])); + + +if (property->cmd ==IPP_CMD_M2M ) + ret =min (count[EXYNOS_DRM_OPS_SRC ], + count[EXYNOS_DRM_OPS_DST ]); +else + ret =max (count[EXYNOS_DRM_OPS_SRC ], + count[EXYNOS_DRM_OPS_DST ]); + +mutex_unlock (&c_node->mem_lock); + +return ret; +} + +static void ipp_clean_cmd_node (struct drm_exynos_ipp_cmd_node *c_node) +{ +DRM_DEBUG_KMS ("%s\n" , __func__); + +/* delete list */ +list_del (&c_node->list); + +/* destroy mutex */ +mutex_destroy (&c_node->cmd_lock); +mutex_destroy (&c_node->mem_lock); +mutex_destroy (&c_node->event_lock); + +/* free command node */ +kfree (c_node->start_work); +kfree (c_node->stop_work); +kfree (c_node->event_work); +kfree (c_node); +} + +static int ipp_set_mem_node (struct exynos_drm_ippdrv *ippdrv, +struct drm_exynos_ipp_cmd_node *c_node, +struct drm_exynos_ipp_mem_node *m_node) +{ +struct exynos_drm_ipp_ops *ops =NULL ; +int ret =0 ; + +DRM_DEBUG_KMS ("%s:node[0x%x]\n" , __func__, (int )m_node); + +if (!m_node) { +DRM_ERROR ("invalid queue node.\n" ); +return -EFAULT ; + } + +mutex_lock (&c_node->mem_lock); + +DRM_DEBUG_KMS ("%s:ops_id[%d]\n" , __func__, m_node->ops_id); + +/* get operations callback */ + ops = ippdrv->ops[m_node->ops_id]; +if (!ops) { +DRM_ERROR ("not support ops.\n" ); + ret = -EFAULT ; + goto err_unlock; + } + +/* set address and enable irq */ +if (ops->set_addr) { + ret = ops->set_addr (ippdrv->dev, &m_node->buf_info, + m_node->buf_id,IPP_BUF_ENQUEUE ); +if (ret) { +DRM_ERROR ("failed to set addr.\n" ); + goto err_unlock; + } + } + +err_unlock: +mutex_unlock (&c_node->mem_lock); +return ret; +} + +static struct drm_exynos_ipp_mem_node + *ipp_get_mem_node (struct drm_device *drm_dev, +struct drm_file *file, +struct drm_exynos_ipp_cmd_node *c_node, +struct drm_exynos_ipp_queue_buf *qbuf) +{ +struct drm_exynos_ipp_mem_node *m_node; +struct drm_exynos_ipp_buf_info buf_info; +void *addr; +int i; + +mutex_lock (&c_node->mem_lock); + + m_node =kzalloc (sizeof (*m_node),GFP_KERNEL ); +if (!m_node) { +DRM_ERROR ("failed to allocate queue node.\n" ); + goto err_unlock; + } + +/* clear base address for error handling */ +memset (&buf_info,0x0 ,sizeof (buf_info)); + +/* operations, buffer id */ + m_node->ops_id = qbuf->ops_id; + m_node->prop_id = qbuf->prop_id; + m_node->buf_id = qbuf->buf_id; + +DRM_DEBUG_KMS ("%s:m_node[0x%x]ops_id[%d]\n" , __func__, + (int )m_node, qbuf->ops_id); +DRM_DEBUG_KMS ("%s:prop_id[%d]buf_id[%d]\n" , __func__, + qbuf->prop_id, m_node->buf_id); + +for_each_ipp_planar (i) { +DRM_DEBUG_KMS ("%s:i[%d]handle[0x%x]\n" , __func__, + i, qbuf->handle[i]); + +/* get dma address by handle */ +if (qbuf->handle[i] !=0 ) { + addr = exynos_drm_gem_get_dma_addr(drm_dev,drivers/gpu/drm/exynos/exynos_drm_ipp.c line 638
Quoted 10 lines
drivers/gpu/drm/exynos/exynos_drm_ipp.c new file +10
-0+ qbuf->handle[i], file); +if (!addr) { +DRM_ERROR ("failed to get addr.\n" ); + goto err_clear; + } + + buf_info.gem_handle[i] = qbuf->handle[i]; + buf_info.base[i] = *(dma_addr_t *) addr; + buf_info.file = file; +DRM_DEBUG_KMS("%s:i[%d]base[0x%x]gem_handle[0x%x]\n",
Quoted 39 lines
drivers/gpu/drm/exynos/exynos_drm_ipp.c new file +39
-0+ __func__, i, buf_info.base[i], + buf_info.gem_handle[i]); + } + } + + m_node->buf_info = buf_info; +list_add_tail (&m_node->list, &c_node->mem_list[qbuf->ops_id]); + +mutex_unlock (&c_node->mem_lock); +return m_node; + +err_clear: +kfree (m_node); + +err_unlock: +mutex_unlock (&c_node->mem_lock); + +return NULL ; +} + +static int ipp_put_mem_node (struct drm_device *drm_dev, +struct drm_exynos_ipp_cmd_node *c_node, +struct drm_exynos_ipp_mem_node *m_node) +{ +int i, ret =0 ; + +DRM_DEBUG_KMS ("%s:node[0x%x]\n" , __func__, (int )m_node); + +if (!m_node) { +DRM_ERROR ("invalid dequeue node.\n" ); +return -EFAULT ; + } + +if (list_empty (&m_node->list)) { +DRM_ERROR ("empty memory node.\n" ); +return -ENOMEM ; + } + +mutex_lock (&c_node->mem_lock);drivers/gpu/drm/exynos/exynos_drm_ipp.c
Quoted 10 lines
drivers/gpu/drm/exynos/exynos_drm_ipp.c new file +10
-0+ +DRM_DEBUG_KMS ("%s:ops_id[%d]\n" , __func__, m_node->ops_id); + +/* put gem buffer */ +for_each_ipp_planar (i) { +struct drm_file *file = m_node->buf_info.file; +unsigned int gem_handle = m_node->buf_info.gem_handle[i]; + +if (gem_handle) + exynos_drm_gem_put_dma_addr(drm_dev, gem_handle,file);
Quoted 162 lines
drivers/gpu/drm/exynos/exynos_drm_ipp.c new file +162
-0+ } + +/* delete list in queue */ +list_del (&m_node->list); +kfree (m_node); + +mutex_unlock (&c_node->mem_lock); +return ret; +} + +static void ipp_free_event (struct drm_pending_event *event) +{ +kfree (event); +} + +static int ipp_get_event (struct drm_device *drm_dev, +struct drm_file *file, +struct drm_exynos_ipp_cmd_node *c_node, +struct drm_exynos_ipp_queue_buf *qbuf) +{ +struct drm_exynos_ipp_send_event *e; +unsigned long flags; + +DRM_DEBUG_KMS ("%s:ops_id[%d]buf_id[%d]\n" , __func__, + qbuf->ops_id, qbuf->buf_id); + + e =kzalloc (sizeof (*e),GFP_KERNEL ); + +if (!e) { +DRM_ERROR ("failed to allocate event.\n" ); +spin_lock_irqsave (&drm_dev->event_lock, flags); + file->event_space +=sizeof (e->event); +spin_unlock_irqrestore (&drm_dev->event_lock, flags); +return -ENOMEM ; + } + +/* make event */ + e->event.base.type =DRM_EXYNOS_IPP_EVENT ; + e->event.base.length =sizeof (e->event); + e->event.user_data = qbuf->user_data; + e->event.prop_id = qbuf->prop_id; + e->event.buf_id[EXYNOS_DRM_OPS_DST ] = qbuf->buf_id; + e->base.event = &e->event.base; + e->base.file_priv = file; + e->base.destroy = ipp_free_event; +list_add_tail (&e->base.link, &c_node->event_list); + +return 0 ; +} + +static void ipp_put_event (struct drm_exynos_ipp_cmd_node *c_node, +struct drm_exynos_ipp_queue_buf *qbuf) +{ +struct drm_exynos_ipp_send_event *e, *te; +int count =0 ; + +if (list_empty (&c_node->event_list)) { +DRM_DEBUG_KMS ("%s:event_list is empty.\n" , __func__); +return ; + } + +list_for_each_entry_safe (e, te, &c_node->event_list, base.link) { +DRM_DEBUG_KMS ("%s:count[%d]e[0x%x]\n" , + __func__, count++, (int )e); + +if (!qbuf) { +/* delete list */ +list_del (&e->base.link); +kfree (e); + }else if (e->event.buf_id[EXYNOS_DRM_OPS_DST ] + == qbuf->buf_id) { +/* delete list */ +list_del (&e->base.link); +kfree (e); +return ; + } + } + +return ; +} + +void ipp_handle_cmd_work (struct device *dev, +struct exynos_drm_ippdrv *ippdrv, +struct drm_exynos_ipp_cmd_work *cmd_work, +struct drm_exynos_ipp_cmd_node *c_node) +{ +struct ipp_context *ctx =get_ipp_context (dev); + + cmd_work->ippdrv = ippdrv; + cmd_work->c_node = c_node; +queue_work (ctx->cmd_workq, (struct work_struct *)cmd_work); +} + +int exynos_drm_ipp_queue_buf (struct drm_device *drm_dev,void *data, +struct drm_file *file) +{ +struct drm_exynos_file_private *file_priv = file->driver_priv; +struct exynos_drm_ipp_private *priv = file_priv->ipp_priv; +struct device *dev = priv->dev; +struct ipp_context *ctx =get_ipp_context (dev); +struct drm_exynos_ipp_queue_buf *qbuf = data; +struct exynos_drm_ippdrv *ippdrv; +struct drm_exynos_ipp_property *property; +struct exynos_drm_ipp_ops *ops; +struct drm_exynos_ipp_cmd_node *c_node; +struct drm_exynos_ipp_mem_node *m_node, *tm_node; +int ret; + +DRM_DEBUG_KMS ("%s\n" , __func__); + +if (!qbuf) { +DRM_ERROR ("invalid buf parameter.\n" ); +return -EINVAL ; + } + + ippdrv =ipp_find_drv_node (qbuf->prop_id); + +if (!ippdrv) { +DRM_ERROR ("failed to get ipp driver.\n" ); +return -EFAULT ; + } + +if (qbuf->ops_id >=EXYNOS_DRM_OPS_MAX ) { +DRM_ERROR ("invalid ops parameter.\n" ); +return -EINVAL ; + } + + ops = ippdrv->ops[qbuf->ops_id]; +if (!ops) { +DRM_ERROR ("failed to get ops.\n" ); +return -EFAULT ; + } + +DRM_DEBUG_KMS ("%s:prop_id[%d]ops_id[%s]buf_id[%d]buf_type[%d]\n" , + __func__, qbuf->prop_id, qbuf->ops_id ?"dst" :"src" , + qbuf->buf_id, qbuf->buf_type); + +/* find command node */ + c_node =ipp_find_id (&ctx->prop_idr, &ctx->prop_lock, + qbuf->prop_id); +if (!c_node) { +DRM_ERROR ("failed to get command node.\n" ); +return -EFAULT ; + } + +/* get property */ + property = &c_node->property; +if (!property) { +DRM_ERROR ("invalid property parameter.\n" ); +return -EINVAL ; + } + +/* buffer control */ +switch (qbuf->buf_type) { +case IPP_BUF_ENQUEUE : +/* get memory node */ + m_node =ipp_get_mem_node (drm_dev, file, c_node, qbuf); +if (!m_node) { +DRM_ERROR ("failed to get m_node.\n" ); +return -EINVAL ; + } +drivers/gpu/drm/exynos/exynos_drm_ipp.c
Quoted 10 lines
drivers/gpu/drm/exynos/exynos_drm_ipp.c new file +10
-0+if (qbuf->ops_id ==EXYNOS_DRM_OPS_DST ) { +/* get event */ + ret =ipp_get_event (drm_dev, file, c_node, qbuf); +if (ret) { +DRM_ERROR ("failed to get event.\n" ); + goto err_clean_node; + } + +if (c_node->state !=IPP_STATE_START ) { + DRM_DEBUG_KMS("%s:bypass for invalidstate.\n"
Quoted 16 lines
drivers/gpu/drm/exynos/exynos_drm_ipp.c new file +16
-0+ , __func__); +break ; + } + +if (!ipp_check_mem_list (c_node)) { +DRM_DEBUG_KMS ("%s:empty memory.\n" + , __func__); +break ; + } + +/* +* If set source, destination buffer and enable pm +* m2m operations need start operations in queue +*/ +if (property->cmd ==IPP_CMD_M2M ) { + struct drm_exynos_ipp_cmd_work *cmd_work =drivers/gpu/drm/exynos/exynos_drm_ipp.c
Quoted 10 lines
drivers/gpu/drm/exynos/exynos_drm_ipp.c new file +10
-0+ c_node->start_work; + + cmd_work->ctrl =IPP_CTRL_PLAY ; +ipp_handle_cmd_work (dev, ippdrv, cmd_work, + c_node); + }else { +if (ops->set_addr) { + ret = ops->set_addr(ippdrv->dev, + &m_node->buf_info, + m_node->buf_id,
qbuf->buf_type);drivers/gpu/drm/exynos/exynos_drm_ipp.c
Quoted 3 lines
drivers/gpu/drm/exynos/exynos_drm_ipp.c new file +3
-0+if (ret) { + DRM_ERROR( + "failed to setaddr.\n");
Quoted 421 lines
drivers/gpu/drm/exynos/exynos_drm_ipp.c new file +421
-0+ goto err_clean_node; + } + } + } + } +break ; +case IPP_BUF_DEQUEUE : +mutex_lock (&c_node->cmd_lock); + +if (qbuf->ops_id ==EXYNOS_DRM_OPS_DST ) +ipp_put_event (c_node, qbuf); + +/* put memory node */ +if (!list_empty (&c_node->mem_list[qbuf->ops_id])) { +list_for_each_entry_safe (m_node, tm_node, + &c_node->mem_list[qbuf->ops_id], list) { +if (m_node->buf_id == qbuf->buf_id && + m_node->ops_id == qbuf->ops_id) { +/* put memory node */ +ipp_put_mem_node (drm_dev, + c_node, m_node); + } + } + } +mutex_unlock (&c_node->cmd_lock); +break ; +default : +DRM_ERROR ("invalid buffer control.\n" ); +return -EINVAL ; + } + +return 0 ; + +err_clean_node: +DRM_ERROR ("clean memory nodes.\n" ); + +if (!list_empty (&c_node->mem_list[qbuf->ops_id])) { +/* delete list */ +list_for_each_entry_safe (m_node, tm_node, + &c_node->mem_list[qbuf->ops_id], list) { +if (m_node->buf_id == qbuf->buf_id && + m_node->ops_id == qbuf->ops_id) +ipp_put_mem_node (drm_dev, c_node, m_node); + } + } + +return ret; +} +EXPORT_SYMBOL_GPL (exynos_drm_ipp_queue_buf); + +static bool exynos_drm_ipp_check_valid (struct device *dev, +enum drm_exynos_ipp_ctrl ctrl,enum drm_exynos_ipp_state state) +{ +DRM_DEBUG_KMS ("%s\n" , __func__); + +if (ctrl !=IPP_CTRL_PLAY ) { +if (pm_runtime_suspended (dev)) { +DRM_ERROR ("pm:runtime_suspended.\n" ); + goto err_status; + } + } + +switch (ctrl) { +case IPP_CTRL_PLAY : +if (state !=IPP_STATE_IDLE ) + goto err_status; +break ; +case IPP_CTRL_STOP : +if (state ==IPP_STATE_STOP ) + goto err_status; +break ; +case IPP_CTRL_PAUSE : +if (state !=IPP_STATE_START ) + goto err_status; +break ; +case IPP_CTRL_RESUME : +if (state !=IPP_STATE_STOP ) + goto err_status; +break ; +default : +DRM_ERROR ("invalid state.\n" ); + goto err_status; +break ; + } + +return true; + +err_status: +DRM_ERROR ("invalid status:ctrl[%d]state[%d]\n" , ctrl, state); +return false; +} + +int exynos_drm_ipp_cmd_ctrl (struct drm_device *drm_dev,void *data, +struct drm_file *file) +{ +struct drm_exynos_file_private *file_priv = file->driver_priv; +struct exynos_drm_ipp_private *priv = file_priv->ipp_priv; +struct exynos_drm_ippdrv *ippdrv =NULL ; +struct device *dev = priv->dev; +struct ipp_context *ctx =get_ipp_context (dev); +struct drm_exynos_ipp_cmd_ctrl *cmd_ctrl = data; +struct drm_exynos_ipp_cmd_work *cmd_work; +struct drm_exynos_ipp_cmd_node *c_node; +int ret =0 ; + +DRM_DEBUG_KMS ("%s\n" , __func__); + +if (!ctx) { +DRM_ERROR ("invalid context.\n" ); +return -EINVAL ; + } + +if (!cmd_ctrl) { +DRM_ERROR ("invalid control parameter.\n" ); +return -EINVAL ; + } + +DRM_DEBUG_KMS ("%s:ctrl[%d]prop_id[%d]\n" , __func__, + cmd_ctrl->ctrl, cmd_ctrl->prop_id); + + ippdrv =ipp_find_drv_node (cmd_ctrl->prop_id); + +if (!ippdrv) { +DRM_ERROR ("failed to get ipp driver.\n" ); +return -EINVAL ; + } + + c_node =ipp_find_id (&ctx->prop_idr, &ctx->prop_lock, + cmd_ctrl->prop_id); + +if (!c_node) { +DRM_ERROR ("invalid command node list.\n" ); +return -EINVAL ; + } + +if (!exynos_drm_ipp_check_valid (ippdrv->dev, cmd_ctrl->ctrl, + c_node->state)) { +DRM_ERROR ("invalid state.\n" ); +return -EINVAL ; + } + +switch (cmd_ctrl->ctrl) { +case IPP_CTRL_PLAY : +if (pm_runtime_suspended (ippdrv->dev)) +pm_runtime_get_sync (ippdrv->dev); + c_node->state =IPP_STATE_START ; + + cmd_work = c_node->start_work; + cmd_work->ctrl = cmd_ctrl->ctrl; +ipp_handle_cmd_work (dev, ippdrv, cmd_work, c_node); +break ; +case IPP_CTRL_STOP : +cancel_work_sync ((struct work_struct *)c_node->start_work); +cancel_work_sync ((struct work_struct *)c_node->event_work); + c_node->state =IPP_STATE_STOP ; + + cmd_work = c_node->stop_work; + cmd_work->ctrl = cmd_ctrl->ctrl; +ipp_handle_cmd_work (dev, ippdrv, cmd_work, c_node); + +if (!wait_for_completion_timeout (&c_node->stop_complete, +msecs_to_jiffies (200 ))) { +DRM_ERROR ("timeout stop:prop_id[%d]\n" , + c_node->property.prop_id); + } + + ippdrv->dedicated = false; +ipp_clean_cmd_node (c_node); + +if (list_empty (&ippdrv->cmd_list)) +pm_runtime_put_sync (ippdrv->dev); +break ; +case IPP_CTRL_PAUSE : +cancel_work_sync ((struct work_struct *)c_node->start_work); +cancel_work_sync ((struct work_struct *)c_node->event_work); + c_node->state =IPP_STATE_STOP ; + + cmd_work = c_node->stop_work; + cmd_work->ctrl = cmd_ctrl->ctrl; +ipp_handle_cmd_work (dev, ippdrv, cmd_work, c_node); + +if (!wait_for_completion_timeout (&c_node->stop_complete, +msecs_to_jiffies (200 ))) { +DRM_ERROR ("timeout stop:prop_id[%d]\n" , + c_node->property.prop_id); + } +break ; +case IPP_CTRL_RESUME : + c_node->state =IPP_STATE_START ; + + cmd_work = c_node->start_work; + cmd_work->ctrl = cmd_ctrl->ctrl; +ipp_handle_cmd_work (dev, ippdrv, cmd_work, c_node); +break ; +default : +/* ToDo: expand ctrl operation */ +DRM_ERROR ("could not support this state currently.\n" ); + goto err_clear; + } + +DRM_DEBUG_KMS ("%s:done ctrl[%d]prop_id[%d]\n" , __func__, + cmd_ctrl->ctrl, cmd_ctrl->prop_id); + +return 0 ; + +err_clear: +return ret; +} +EXPORT_SYMBOL_GPL (exynos_drm_ipp_cmd_ctrl); + +int exynos_drm_ippnb_register (struct notifier_block *nb) +{ +return blocking_notifier_chain_register ( + &exynos_drm_ippnb_list, nb); +} +EXPORT_SYMBOL_GPL (exynos_drm_ippnb_register); + +int exynos_drm_ippnb_unregister (struct notifier_block *nb) +{ +return blocking_notifier_chain_unregister ( + &exynos_drm_ippnb_list, nb); +} +EXPORT_SYMBOL_GPL (exynos_drm_ippnb_unregister); + +int exynos_drm_ippnb_send_event (unsigned long val,void *v) +{ +return blocking_notifier_call_chain ( + &exynos_drm_ippnb_list, val, v); +} +EXPORT_SYMBOL_GPL (exynos_drm_ippnb_send_event); + +static int ipp_set_property (struct exynos_drm_ippdrv *ippdrv, +struct drm_exynos_ipp_property *property) +{ +struct exynos_drm_ipp_ops *ops =NULL ; +int ret, i, swap =0 ; + +if (!property) { +DRM_ERROR ("invalid property parameter.\n" ); +return -EINVAL ; + } + +DRM_DEBUG_KMS ("%s:prop_id[%d]\n" , __func__, property->prop_id); + +/* reset h/w block */ +if (ippdrv->reset && + ippdrv->reset (ippdrv->dev)) { +DRM_ERROR ("failed to reset.\n" ); +return -EINVAL ; + } + +/* set source,destination operations */ +for_each_ipp_ops (i) { +/* ToDo: integrate property and config */ +struct drm_exynos_ipp_config *config = + &property->config[i]; + + ops = ippdrv->ops[i]; +if (!ops || !config) { +DRM_ERROR ("not support ops and config.\n" ); +return -EINVAL ; + } + +/* set format */ +if (ops->set_fmt) { + ret = ops->set_fmt (ippdrv->dev, config->fmt); +if (ret) { +DRM_ERROR ("not support format.\n" ); +return ret; + } + } + +/* set transform for rotation, flip */ +if (ops->set_transf) { + swap = ops->set_transf (ippdrv->dev, config->degree, + config->flip); +if (swap <0 ) { +DRM_ERROR ("not support tranf.\n" ); +return -EINVAL ; + } + } + +/* set size */ +if (ops->set_size) { + ret = ops->set_size (ippdrv->dev, swap, &config->pos, + &config->sz); +if (ret) { +DRM_ERROR ("not support size.\n" ); +return ret; + } + } + } + +return 0 ; +} + +static int ipp_start_property (struct exynos_drm_ippdrv *ippdrv, +struct drm_exynos_ipp_cmd_node *c_node) +{ +struct drm_exynos_ipp_mem_node *m_node; +struct drm_exynos_ipp_property *property = &c_node->property; +struct list_head *head; +int ret, i; + +DRM_DEBUG_KMS ("%s:prop_id[%d]\n" , __func__, property->prop_id); + +/* store command info in ippdrv */ + ippdrv->cmd = c_node; + +if (!ipp_check_mem_list (c_node)) { +DRM_DEBUG_KMS ("%s:empty memory.\n" , __func__); +return -ENOMEM ; + } + +/* set current property in ippdrv */ + ret =ipp_set_property (ippdrv, property); +if (ret) { +DRM_ERROR ("failed to set property.\n" ); + ippdrv->cmd =NULL ; +return ret; + } + +/* check command */ +switch (property->cmd) { +case IPP_CMD_M2M : +for_each_ipp_ops (i) { +/* source/destination memory list */ + head = &c_node->mem_list[i]; + +/* get first entry */ + m_node =list_first_entry (head, + struct drm_exynos_ipp_mem_node, list); +if (!m_node) { +DRM_ERROR ("failed to get node.\n" ); + ret = -EFAULT ; +return ret; + } + +DRM_DEBUG_KMS ("%s:m_node[0x%x]\n" , + __func__, (int )m_node); + +/* set memory node to ippdrv */ + ret =ipp_set_mem_node (ippdrv, c_node, m_node); +if (ret) { +DRM_ERROR ("failed to set m node.\n" ); +return ret; + } + } +break ; +case IPP_CMD_WB : +/* destination memory list */ + head = &c_node->mem_list[EXYNOS_DRM_OPS_DST ]; + +/* get list entry */ +list_for_each_entry (m_node, head, list) { +/* set memory node to ippdrv */ + ret =ipp_set_mem_node (ippdrv, c_node, m_node); +if (ret) { +DRM_ERROR ("failed to set m node.\n" ); +return ret; + } + } +break ; +case IPP_CMD_OUTPUT : +/* source memory list */ + head = &c_node->mem_list[EXYNOS_DRM_OPS_SRC ]; + +/* get list entry */ +list_for_each_entry (m_node, head, list) { +/* set memory node to ippdrv */ + ret =ipp_set_mem_node (ippdrv, c_node, m_node); +if (ret) { +DRM_ERROR ("failed to set m node.\n" ); +return ret; + } + } +break ; +default : +DRM_ERROR ("invalid operations.\n" ); +return -EINVAL ; + } + +DRM_DEBUG_KMS ("%s:cmd[%d]\n" , __func__, property->cmd); + +/* start operations */ +if (ippdrv->start) { + ret = ippdrv->start (ippdrv->dev, property->cmd); +if (ret) { +DRM_ERROR ("failed to start ops.\n" ); +return ret; + } + } + +return 0 ; +} + +static int ipp_stop_property (struct drm_device *drm_dev, +struct exynos_drm_ippdrv *ippdrv, +struct drm_exynos_ipp_cmd_node *c_node) +{ +struct drm_exynos_ipp_mem_node *m_node, *tm_node; +struct drm_exynos_ipp_property *property = &c_node->property; +struct list_head *head; +int ret, i; + +DRM_DEBUG_KMS ("%s:prop_id[%d]\n" , __func__, property->prop_id); + +/* put event */ +ipp_put_event (c_node,NULL ); + +/* check command */ +switch (property->cmd) { +case IPP_CMD_M2M : +for_each_ipp_ops (i) { +/* source/destination memory list */ + head = &c_node->mem_list[i]; + +if (list_empty (head)) { +DRM_DEBUG_KMS ("%s:mem_list is empty.\n" , + __func__); +break ;drivers/gpu/drm/exynos/exynos_drm_ipp.c
Quoted 10 lines
drivers/gpu/drm/exynos/exynos_drm_ipp.c new file +10
-0+ } + +/* get list entry */ +list_for_each_entry_safe (m_node, tm_node, + head, list) { +/* put memory node */ + ret =ipp_put_mem_node (drm_dev, c_node, + m_node); +if (ret) { + DRM_ERROR("failed to putm_node.\n");
Quoted 76 lines
drivers/gpu/drm/exynos/exynos_drm_ipp.c new file +76
-0+ goto err_clear; + } + } + } +break ; +case IPP_CMD_WB : +/* destination memory list */ + head = &c_node->mem_list[EXYNOS_DRM_OPS_DST ]; + +if (list_empty (head)) { +DRM_DEBUG_KMS ("%s:mem_list is empty.\n" , __func__); +break ; + } + +/* get list entry */ +list_for_each_entry_safe (m_node, tm_node, head, list) { +/* put memory node */ + ret =ipp_put_mem_node (drm_dev, c_node, m_node); +if (ret) { +DRM_ERROR ("failed to put m_node.\n" ); + goto err_clear; + } + } +break ; +case IPP_CMD_OUTPUT : +/* source memory list */ + head = &c_node->mem_list[EXYNOS_DRM_OPS_SRC ]; + +if (list_empty (head)) { +DRM_DEBUG_KMS ("%s:mem_list is empty.\n" , __func__); +break ; + } + +/* get list entry */ +list_for_each_entry_safe (m_node, tm_node, head, list) { +/* put memory node */ + ret =ipp_put_mem_node (drm_dev, c_node, m_node); +if (ret) { +DRM_ERROR ("failed to put m_node.\n" ); + goto err_clear; + } + } +break ; +default : +DRM_ERROR ("invalid operations.\n" ); + ret = -EINVAL ; + goto err_clear; + } + +err_clear: +/* stop operations */ +if (ippdrv->stop) + ippdrv->stop (ippdrv->dev, property->cmd); + +return 0 ; +} + +void ipp_sched_cmd (struct work_struct *work) +{ +struct drm_exynos_ipp_cmd_work *cmd_work = + (struct drm_exynos_ipp_cmd_work *)work; +struct exynos_drm_ippdrv *ippdrv; +struct drm_exynos_ipp_cmd_node *c_node; +struct drm_exynos_ipp_property *property; +int ret; + +DRM_DEBUG_KMS ("%s\n" , __func__); + + ippdrv = cmd_work->ippdrv; +if (!ippdrv) { +DRM_ERROR ("invalid ippdrv list.\n" ); +return ; + } + + c_node = cmd_work->c_node; +if (!c_node) {
Quoted 8 lines
drivers/gpu/drm/exynos/exynos_drm_ipp.c line 1397
Quoted 7 lines
drivers/gpu/drm/exynos/exynos_drm_ipp.c new file +7
-0+DRM_ERROR ("invalid command node list.\n" ); +return ; + } + +mutex_lock (&c_node->cmd_lock); + +/* get property */ Useless comment.
done.
Quoted 13 lines
drivers/gpu/drm/exynos/exynos_drm_ipp.c line 1408
Quoted 12 lines
drivers/gpu/drm/exynos/exynos_drm_ipp.c new file +11
-0+ property = &c_node->property; +if (!property) { +DRM_ERROR ("failed to get property:prop_id[%d]\n" , + c_node->property.prop_id); + goto err_unlock; + } + +switch (cmd_work->ctrl) { +case IPP_CTRL_PLAY : +case IPP_CTRL_RESUME : +/* start property */ Useless comment.
done.
Quoted 10 lines
drivers/gpu/drm/exynos/exynos_drm_ipp.c line 1416
Quoted 9 lines
drivers/gpu/drm/exynos/exynos_drm_ipp.c new file +8
-0+ ret =ipp_start_property (ippdrv, c_node); +if (ret) { +DRM_ERROR ("failed to start property:prop_id[%d]\n" , + c_node->property.prop_id); + goto err_unlock; + } + +if (property->cmd ==IPP_CMD_M2M ) {Leave comment to why to do this if cmd is
IPP_CMD_M2M.
Added comment.
M2M case supports queue buffers.
but runtime is only one. so, we are using wait completion in all queued buffer. I described this operation using my comment.
Quoted 71 lines
drivers/gpu/drm/exynos/exynos_drm_ipp.c
Quoted 3 lines
drivers/gpu/drm/exynos/exynos_drm_ipp.c new file +2
-0+if (!wait_for_completion_timeout + (&c_node->start_complete,
msecs_to_jiffies(200))) {Quoted 67 lines
drivers/gpu/drm/exynos/exynos_drm_ipp.c new file +67
-0+DRM_ERROR ("timeout event:prop_id[%d]\n" , + c_node->property.prop_id); + goto err_unlock; + } + } +break ; +case IPP_CTRL_STOP : +case IPP_CTRL_PAUSE : + ret =ipp_stop_property (ippdrv->drm_dev, ippdrv, + c_node); +if (ret) { +DRM_ERROR ("failed to stop property.\n" ); + goto err_unlock; + } + +complete (&c_node->stop_complete); +break ; +default : +DRM_ERROR ("unknown control type\n" ); +break ; + } + +DRM_DEBUG_KMS ("%s:ctrl[%d] done.\n" , __func__, cmd_work->ctrl); + +err_unlock: +mutex_unlock (&c_node->cmd_lock); +} + +static int ipp_send_event (struct exynos_drm_ippdrv *ippdrv, +struct drm_exynos_ipp_cmd_node *c_node,int *buf_id) +{ +struct drm_device *drm_dev = ippdrv->drm_dev; +struct drm_exynos_ipp_property *property = &c_node->property; +struct drm_exynos_ipp_mem_node *m_node; +struct drm_exynos_ipp_queue_buf qbuf; +struct drm_exynos_ipp_send_event *e; +struct list_head *head; +struct timeval now; +unsigned long flags; +u32 tbuf_id[EXYNOS_DRM_OPS_MAX ] = {0 , }; +int ret, i; + +for_each_ipp_ops (i) +DRM_DEBUG_KMS ("%s:%s buf_id[%d]\n" , __func__, + i ?"dst" :"src" , buf_id[i]); + +if (!drm_dev) { +DRM_ERROR ("failed to get drm_dev.\n" ); +return -EINVAL ; + } + +if (!property) { +DRM_ERROR ("failed to get property.\n" ); +return -EINVAL ; + } + +if (list_empty (&c_node->event_list)) { +DRM_DEBUG_KMS ("%s:event list is empty.\n" , __func__); +return 0 ; + } + +if (!ipp_check_mem_list (c_node)) { +DRM_DEBUG_KMS ("%s:empty memory.\n" , __func__); +return 0 ; + } + +/* check command */
Quoted 8 lines
drivers/gpu/drm/exynos/exynos_drm_ipp.c line 1213
Quoted 7 lines
drivers/gpu/drm/exynos/exynos_drm_ipp.c new file +7
-0+switch (property->cmd) { +case IPP_CMD_M2M : +for_each_ipp_ops (i) { +/* source/destination memory list */ + head = &c_node->mem_list[i]; + +/* get first entry */ Useless comment.
done.
Quoted 14 lines
drivers/gpu/drm/exynos/exynos_drm_ipp.c line 1504
Quoted 13 lines
drivers/gpu/drm/exynos/exynos_drm_ipp.c new file +12
-0+ m_node =list_first_entry (head, + struct drm_exynos_ipp_mem_node, list); +if (!m_node) { +DRM_ERROR ("empty memory node.\n" ); +return -ENOMEM ; + } + + tbuf_id[i] = m_node->buf_id; +DRM_DEBUG_KMS ("%s:%s buf_id[%d]\n" , __func__, + i ?"dst" :"src" , tbuf_id[i]); + +/* put memory node */ Useless comment. why this memory node should be putted?
because we are this buffer use done. and next time enqueu buffer If needed.
I think your comment is optimization issue about queue buffer. I will think about remain buffer list.
Quoted 49 lines
Quoted 49 lines
drivers/gpu/drm/exynos/exynos_drm_ipp.c new file +48
-0+ ret =ipp_put_mem_node (drm_dev, c_node, m_node); +if (ret) +DRM_ERROR ("failed to put m_node.\n" ); + } +break ; +case IPP_CMD_WB : +/* clear buf for finding */ +memset (&qbuf,0x0 ,sizeof (qbuf)); + qbuf.ops_id =EXYNOS_DRM_OPS_DST ; + qbuf.buf_id = buf_id[EXYNOS_DRM_OPS_DST ]; + +/* get memory node entry */ + m_node =ipp_find_mem_node (c_node, &qbuf); +if (!m_node) { +DRM_ERROR ("empty memory node.\n" ); +return -ENOMEM ; + } + + tbuf_id[EXYNOS_DRM_OPS_DST ] = m_node->buf_id; + +/* put memory node */ + ret =ipp_put_mem_node (drm_dev, c_node, m_node); +if (ret) +DRM_ERROR ("failed to put m_node.\n" ); +break ; +case IPP_CMD_OUTPUT : +/* source memory list */ + head = &c_node->mem_list[EXYNOS_DRM_OPS_SRC ]; + +/* get first entry */ + m_node =list_first_entry (head, + struct drm_exynos_ipp_mem_node, list); +if (!m_node) { +DRM_ERROR ("empty memory node.\n" ); +return -ENOMEM ; + } + + tbuf_id[EXYNOS_DRM_OPS_SRC ] = m_node->buf_id; + +/* put memory node */ + ret =ipp_put_mem_node (drm_dev, c_node, m_node); +if (ret) +DRM_ERROR ("failed to put m_node.\n" ); +break ; +default : +DRM_ERROR ("invalid operations.\n" ); +return -EINVAL ; + }
Quoted 8 lines
drivers/gpu/drm/exynos/exynos_drm_ipp.c line 1559
Quoted 7 lines
drivers/gpu/drm/exynos/exynos_drm_ipp.c new file +7
-0+ +/* ToDo: Fix buffer id */ +if (tbuf_id[EXYNOS_DRM_OPS_DST ] != buf_id[EXYNOS_DRM_OPS_DST ]) +DRM_ERROR ("failed to match buf_id[%d %d]prop_id[%d]\n" , + tbuf_id[1 ], buf_id[1 ], property->prop_id); + +/* get first event entry */ Levae comment to why it should get first event to do what?
Added comments.
and command node have event_list. this event_list enqueue using queue_buf ioctl. so, first event is old queued buffer.
so, we always getting first event list.
Quoted 55 lines
Quoted 55 lines
drivers/gpu/drm/exynos/exynos_drm_ipp.c new file +27
-0+ e =list_first_entry (&c_node->event_list, + struct drm_exynos_ipp_send_event, base.link); + +if (!e) { +DRM_ERROR ("empty event.\n" ); +return -EINVAL ; + } + +do_gettimeofday (&now); +DRM_DEBUG_KMS ("%s:tv_sec[%ld]tv_usec[%ld]\n" + , __func__, now.tv_sec, now.tv_usec); + e->event.tv_sec = now.tv_sec; + e->event.tv_usec = now.tv_usec; + e->event.prop_id = property->prop_id; + +/* set buffer id about source destination */ +for_each_ipp_ops (i) + e->event.buf_id[i] = tbuf_id[i]; +/* ToDo: compare index. If needed */ + +spin_lock_irqsave (&drm_dev->event_lock, flags); +list_move_tail (&e->base.link, &e->base.file_priv->event_list); +wake_up_interruptible (&e->base.file_priv->event_wait); +spin_unlock_irqrestore (&drm_dev->event_lock, flags); + + DRM_DEBUG_KMS("%s:done cmd[%d]prop_id[%d]buf_id[%d]\n", __func__, + property->cmd, property->prop_id,tbuf_id[EXYNOS_DRM_OPS_DST]);
drivers/gpu/drm/exynos/exynos_drm_ipp.c new file +26
-0+ +return 0 ; +} + +void ipp_sched_event (struct work_struct *work) +{ +struct drm_exynos_ipp_event_work *event_work = + (struct drm_exynos_ipp_event_work *)work; +struct exynos_drm_ippdrv *ippdrv; +struct drm_exynos_ipp_cmd_node *c_node; +int ret; + +if (!event_work) { +DRM_ERROR ("failed to get event_work.\n" ); +return ; + } + +DRM_DEBUG_KMS ("%s:buf_id[%d]\n" , __func__, + event_work->buf_id[EXYNOS_DRM_OPS_DST ]); + + ippdrv = event_work->ippdrv; +if (!ippdrv) { +DRM_ERROR ("failed to get ipp driver.\n" ); +return ; + } +
Quoted 8 lines
drivers/gpu/drm/exynos/exynos_drm_ipp.c line 1619
Quoted 7 lines
drivers/gpu/drm/exynos/exynos_drm_ipp.c new file +7
-0+ c_node = ippdrv->cmd; +if (!c_node) { +DRM_ERROR ("failed to get command node.\n" ); +return ; + } + +if (c_node->state !=IPP_STATE_START ) {Leave comment to why and then how.
Added comments.
If user process close our fd. than we going out.
M2M case need to sync so, we are called complete.
Quoted 29 lines
Quoted 29 lines
drivers/gpu/drm/exynos/exynos_drm_ipp.c new file +21
-0+DRM_DEBUG_KMS ("%s:bypass state[%d]prop_id[%d]\n" , + __func__, c_node->state, c_node->property.prop_id); + goto err_completion; + } + +mutex_lock (&c_node->event_lock); + + ret =ipp_send_event (ippdrv, c_node, event_work->buf_id); +if (ret) { +DRM_ERROR ("failed to send event.\n" ); + goto err_completion; + } + +err_completion: +if (c_node->property.cmd ==IPP_CMD_M2M ) +complete (&c_node->start_complete); + +mutex_unlock (&c_node->event_lock); +} + +static int ipp_subdrv_probe(struct drm_device *drm_dev, struct device*dev)
drivers/gpu/drm/exynos/exynos_drm_ipp.c new file +5
-0+{ +struct ipp_context *ctx =get_ipp_context (dev); +struct exynos_drm_ippdrv *ippdrv; +int ret, count =0 ; +
Quoted 8 lines
drivers/gpu/drm/exynos/exynos_drm_ipp.c line 1652
Quoted 7 lines
drivers/gpu/drm/exynos/exynos_drm_ipp.c new file +7
-0+DRM_DEBUG_KMS ("%s\n" , __func__); + +/* get ipp driver entry */ +list_for_each_entry (ippdrv, &exynos_drm_ippdrv_list, drv_list) { + ippdrv->drm_dev = drm_dev; + +/* create ipp id */ Useless comment.
done.
Quoted 7 lines
drivers/gpu/drm/exynos/exynos_drm_ipp.c line 1657
Quoted 6 lines
drivers/gpu/drm/exynos/exynos_drm_ipp.c new file +5
-0+ ret =ipp_create_id (&ctx->ipp_idr, &ctx->ipp_lock, ippdrv, + &ippdrv->ipp_id); +if (ret) { +DRM_ERROR ("failed to create id.\n" ); + goto err_idr;At this point, a new idr isn't created.
Yes if failed. so, we don't use this ipp driver.
Quoted 98 lines
Quoted 41 lines
drivers/gpu/drm/exynos/exynos_drm_ipp.c new file +3
-0+ } + + DRM_DEBUG_KMS("%s:count[%d]ippdrv[0x%x]ipp_id[%d]\n",
__func__,drivers/gpu/drm/exynos/exynos_drm_ipp.c new file +29
-0+ count++, (int)ippdrv, ippdrv->ipp_id); + +if (ippdrv->ipp_id ==0 ) { +DRM_ERROR ("failed to get ipp_id[%d]\n" , + ippdrv->ipp_id); + goto err_idr; + } + +/* store parent device for node */ + ippdrv->parent_dev = dev; + +/* store event work queue and handler */ + ippdrv->event_workq = ctx->event_workq; + ippdrv->sched_event = ipp_sched_event; +INIT_LIST_HEAD (&ippdrv->cmd_list); + } + +return 0 ; + +err_idr: +idr_remove_all (&ctx->ipp_idr); +idr_remove_all (&ctx->prop_idr); +idr_destroy (&ctx->ipp_idr); +idr_destroy (&ctx->prop_idr); + +return ret; +} + +static void ipp_subdrv_remove(struct drm_device *drm_dev, struct device*dev)
drivers/gpu/drm/exynos/exynos_drm_ipp.c new file +5
-0+{ +struct exynos_drm_ippdrv *ippdrv; + +DRM_DEBUG_KMS ("%s\n" , __func__); +drivers/gpu/drm/exynos/exynos_drm_ipp.c
Quoted 10 lines
drivers/gpu/drm/exynos/exynos_drm_ipp.c new file +10
-0+/* get ipp driver entry */ +list_for_each_entry (ippdrv, &exynos_drm_ippdrv_list, drv_list) { + ippdrv->drm_dev =NULL ; +exynos_drm_ippdrv_unregister (ippdrv); + } + +/* ToDo: free notifier callback list if needed */ +} + +static int ipp_subdrv_open(struct drm_device *drm_dev, struct device*dev,
Quoted 46 lines
drivers/gpu/drm/exynos/exynos_drm_ipp.c new file +25
-0+ struct drm_file *file) +{ +struct drm_exynos_file_private *file_priv = file->driver_priv; +struct exynos_drm_ipp_private *priv; + +DRM_DEBUG_KMS ("%s\n" , __func__); + +/* ToDo: multi device open */ + + priv =kzalloc (sizeof (*priv),GFP_KERNEL ); +if (!priv) { +DRM_ERROR ("failed to allocate priv.\n" ); +return -ENOMEM ; + } + priv->dev = dev; + file_priv->ipp_priv = priv; + +INIT_LIST_HEAD (&priv->event_list); + +DRM_DEBUG_KMS ("%s:done priv[0x%x]\n" , __func__, (int )priv); + +return 0 ; +} + +static void ipp_subdrv_close(struct drm_device *drm_dev, struct device*dev,
drivers/gpu/drm/exynos/exynos_drm_ipp.c new file +20
-0+ struct drm_file *file) +{ +struct drm_exynos_file_private *file_priv = file->driver_priv; +struct exynos_drm_ipp_private *priv = file_priv->ipp_priv; +struct exynos_drm_ippdrv *ippdrv =NULL ; +struct drm_exynos_ipp_cmd_node *c_node, *tc_node; +int count =0 ; + +DRM_DEBUG_KMS ("%s:for priv[0x%x]\n" , __func__, (int )priv); + +if (list_empty (&exynos_drm_ippdrv_list)) { +DRM_DEBUG_KMS ("%s:ippdrv_list is empty.\n" , __func__); + goto err_clear; + } + +list_for_each_entry (ippdrv, &exynos_drm_ippdrv_list, drv_list) { +if (list_empty (&ippdrv->cmd_list)) +continue ; + + list_for_each_entry_safe(c_node, tc_node,
Quoted 8 lines
drivers/gpu/drm/exynos/exynos_drm_ipp.c line 1755
Quoted 6 lines
drivers/gpu/drm/exynos/exynos_drm_ipp.c new file +6
-0+ &ippdrv->cmd_list, list) { +DRM_DEBUG_KMS ("%s:count[%d]ippdrv[0x%x]\n" , + __func__, count++, (int )ippdrv); + +if (c_node->priv == priv) { +if (c_node->state ==IPP_STATE_START ) {Leave comments to why
IPP_STATE_STARTshould be checked and then relevant driver should be stopped at here.
Added comments.
We need to stop current operation at unnormal close state about our fd. (e.g process killed.)
so, we need to make cleanup of command node at this time. maybe If normal state, we are finished cleanup at stop command ctrl.
Quoted 9 lines
drivers/gpu/drm/exynos/exynos_drm_ipp.c line 1762
Quoted 8 lines
drivers/gpu/drm/exynos/exynos_drm_ipp.c new file +7
-0+ipp_stop_property (drm_dev, ippdrv, + c_node); + c_node->state =IPP_STATE_STOP ; + } + + ippdrv->dedicated = false; +ipp_clean_cmd_node (c_node);Leave comments to why
c_nodeshould be cleaned at here.
ditto.
Quoted 4 lines
drivers/gpu/drm/exynos/exynos_drm_ipp.c
Quoted 2 lines
drivers/gpu/drm/exynos/exynos_drm_ipp.c new file +1
-0+if (list_empty (&ippdrv->cmd_list))Also. such as 'each driver has no any command to process so the ipp driver should be off.'
ditto.
Quoted 21 lines
Quoted 21 lines
drivers/gpu/drm/exynos/exynos_drm_ipp.c new file +20
-0+pm_runtime_put_sync (ippdrv->dev); + } + } + } + +err_clear: +kfree (priv); + +return ; +} + +static int __devinit ipp_probe (struct platform_device *pdev) +{ +struct device *dev = &pdev->dev; +struct ipp_context *ctx; +struct exynos_drm_subdrv *subdrv; +int ret = -EINVAL ; + + ctx =kzalloc (sizeof (*ctx),GFP_KERNEL ); +if (!ctx)
Quoted 8 lines
drivers/gpu/drm/exynos/exynos_drm_ipp.c line 1789
Quoted 6 lines
drivers/gpu/drm/exynos/exynos_drm_ipp.c new file +6
-0+return -ENOMEM ; + +DRM_DEBUG_KMS ("%s\n" , __func__); + +mutex_init (&ctx->ipp_lock); +mutex_init (&ctx->prop_lock);Leave a blank line.
done.
Quoted 3 lines
drivers/gpu/drm/exynos/exynos_drm_ipp.c line 1790
Quoted 2 lines
drivers/gpu/drm/exynos/exynos_drm_ipp.c new file +1
-0+/* init ipp driver idr */ Useless comment.
done.
Quoted 5 lines
drivers/gpu/drm/exynos/exynos_drm_ipp.c line 1792
Quoted 3 lines
drivers/gpu/drm/exynos/exynos_drm_ipp.c new file +2
-0+idr_init (&ctx->ipp_idr); +idr_init (&ctx->prop_idr);Leave a blank line.
done.
Quoted 3 lines
drivers/gpu/drm/exynos/exynos_drm_ipp.c line 1793
Quoted 2 lines
drivers/gpu/drm/exynos/exynos_drm_ipp.c new file +1
-0+/* create single thread for ipp event */ Useless comment. Leave how this
event_workqis used instead.
done.
Quoted 10 lines
drivers/gpu/drm/exynos/exynos_drm_ipp.c line 1801
Quoted 9 lines
drivers/gpu/drm/exynos/exynos_drm_ipp.c new file +8
-0+ ctx->event_workq =create_singlethread_workqueue ("ipp_event" ); +if (!ctx->event_workq) { +dev_err (dev,"failed to create event workqueue\n" ); + ret = -EINVAL ; + goto err_clear; + } + +/* create single thread for ipp command */ Useless comment. Leave how this
event_workqis used instead.
done.
Quoted 10 lines
Quoted 10 lines
drivers/gpu/drm/exynos/exynos_drm_ipp.c new file +9
-0+ ctx->cmd_workq =create_singlethread_workqueue ("ipp_cmd" ); +if (!ctx->cmd_workq) { +dev_err (dev,"failed to create cmd workqueue\n" ); + ret = -EINVAL ; + goto err_event_workq; + } + +/* set sub driver informations */ + subdrv = &ctx->subdrv;
Quoted 8 lines
drivers/gpu/drm/exynos/exynos_drm_ipp.c line 1817
Quoted 7 lines
drivers/gpu/drm/exynos/exynos_drm_ipp.c new file +7
-0+ subdrv->dev = dev; + subdrv->probe = ipp_subdrv_probe; + subdrv->remove = ipp_subdrv_remove; + subdrv->open = ipp_subdrv_open; + subdrv->close = ipp_subdrv_close; + +/* set driver data */ Useless comment.
done.
Quoted 3 lines
drivers/gpu/drm/exynos/exynos_drm_ipp.c line 1818
Quoted 2 lines
drivers/gpu/drm/exynos/exynos_drm_ipp.c new file +1
-0+platform_set_drvdata (pdev, ctx);Useless comment.
done.
Quoted 642 lines
Quoted 273 lines
drivers/gpu/drm/exynos/exynos_drm_ipp.c new file +115
-0+ +/* register sub driver */ + ret =exynos_drm_subdrv_register (subdrv); +if (ret <0 ) { +DRM_ERROR ("failed to register drm ipp device.\n" ); + goto err_cmd_workq; + } + +dev_info (&pdev->dev,"drm ipp registered successfully.\n" ); + +return 0 ; + +err_cmd_workq: +destroy_workqueue (ctx->cmd_workq); +err_event_workq: +destroy_workqueue (ctx->event_workq); +err_clear: +kfree (ctx); + +return ret; +} + +static int __devexit ipp_remove(struct platform_device *pdev) +{ +struct ipp_context *ctx =platform_get_drvdata (pdev); + +DRM_DEBUG_KMS ("%s\n" , __func__); + +/* unregister sub driver */ +exynos_drm_subdrv_unregister (&ctx->subdrv); + +/* remove,destroy ipp idr */ +idr_remove_all (&ctx->ipp_idr); +idr_remove_all (&ctx->prop_idr); +idr_destroy (&ctx->ipp_idr); +idr_destroy (&ctx->prop_idr); + +/* destroy command, event work queue */ +destroy_workqueue (ctx->cmd_workq); +destroy_workqueue (ctx->event_workq); + +kfree (ctx); + +return 0 ; +} + +static int ipp_power_ctrl (struct ipp_context *ctx,bool enable) +{ +/* ToDo: Need to implement power and sysmmu ctrl. */ +DRM_DEBUG_KMS ("%s:enable[%d]\n" , __func__, enable); + +return 0 ; +} + +#ifdef CONFIG_PM_SLEEP +static int ipp_suspend (struct device *dev) +{ +struct ipp_context *ctx =get_ipp_context (dev); + +DRM_DEBUG_KMS ("%s\n" , __func__); + +if (pm_runtime_suspended (dev)) +return 0 ; + +return ipp_power_ctrl (ctx, false); +} + +static int ipp_resume (struct device *dev) +{ +struct ipp_context *ctx =get_ipp_context (dev); + +DRM_DEBUG_KMS ("%s\n" , __func__); + +if (!pm_runtime_suspended (dev)) +return ipp_power_ctrl (ctx, true); + +return 0 ; +} +#endif + +#ifdef CONFIG_PM_RUNTIME +static int ipp_runtime_suspend (struct device *dev) +{ +struct ipp_context *ctx =get_ipp_context (dev); + +DRM_DEBUG_KMS ("%s\n" , __func__); + +return ipp_power_ctrl (ctx, false); +} + +static int ipp_runtime_resume (struct device *dev) +{ +struct ipp_context *ctx =get_ipp_context (dev); + +DRM_DEBUG_KMS ("%s\n" , __func__); + +return ipp_power_ctrl (ctx, true); +} +#endif + +static const struct dev_pm_ops ipp_pm_ops = { + SET_SYSTEM_SLEEP_PM_OPS(ipp_suspend, ipp_resume) +SET_RUNTIME_PM_OPS (ipp_runtime_suspend, ipp_runtime_resume,NULL ) +}; + +struct platform_driver ipp_driver = { + .probe = ipp_probe, + .remove =__devexit_p (ipp_remove), + .driver = { + .name ="exynos-drm-ipp" , + .owner =THIS_MODULE , + .pm = &ipp_pm_ops, + }, +}; +drivers/gpu/drm/exynos/exynos_drm_ipp.h new file +9
-0@@ -0,0 +1,268 @@ +/* +* Copyright (c) 2012 Samsung Electronics Co., Ltd. +* +* Authors: +* Eunchul Kim <[email protected]> +* Jinyoung Jeon <[email protected]> +* Sangmin Lee <[email protected]> +* +* Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ */drivers/gpu/drm/exynos/exynos_drm_ipp.h new file +113
-0+ +#ifndef _EXYNOS_DRM_IPP_H_ +#define _EXYNOS_DRM_IPP_H_ + +#define for_each_ipp_ops (pos) \ + for (pos = 0; pos < EXYNOS_DRM_OPS_MAX; pos++) +#define for_each_ipp_planar (pos) \ + for (pos = 0; pos < EXYNOS_DRM_PLANAR_MAX; pos++) + +#define IPP_GET_LCD_WIDTH _IOR('F', 302, int) +#define IPP_GET_LCD_HEIGHT _IOR('F', 303, int) +#define IPP_SET_WRITEBACK _IOW('F', 304, u32) + +/* definition of state */ +enum drm_exynos_ipp_state { +IPP_STATE_IDLE , +IPP_STATE_START , +IPP_STATE_STOP , +}; + +/* +* A structure of command work information. +* @work: work structure. +* @ippdrv: current work ippdrv. +* @c_node: command node information. +* @ctrl: command control. +*/ +struct drm_exynos_ipp_cmd_work { +struct work_struct work; +struct exynos_drm_ippdrv *ippdrv; +struct drm_exynos_ipp_cmd_node *c_node; +enum drm_exynos_ipp_ctrl ctrl; +}; + +/* +* A structure of command node. +* +* @priv: IPP private infomation. +* @list: list head to command queue information. +* @event_list: list head of event. +* @mem_list: list head to source,destination memory queue information. +* @cmd_lock: lock for synchronization of access to ioctl. +* @mem_lock: lock for synchronization of access to memory nodes. +* @event_lock: lock for synchronization of access to scheduled event. +* @start_complete: completion of start of command. +* @stop_complete: completion of stop of command. +* @property: property information. +* @start_work: start command work structure. +* @stop_work: stop command work structure. +* @event_work: event work structure. +* @state: state of command node. +*/ +struct drm_exynos_ipp_cmd_node { +struct exynos_drm_ipp_private *priv; +struct list_head list; +struct list_head event_list; +struct list_head mem_list[EXYNOS_DRM_OPS_MAX ]; +struct mutex cmd_lock; +struct mutex mem_lock; +struct mutex event_lock; +struct completion start_complete; +struct completion stop_complete; +struct drm_exynos_ipp_property property; +struct drm_exynos_ipp_cmd_work *start_work; +struct drm_exynos_ipp_cmd_work *stop_work; +struct drm_exynos_ipp_event_work *event_work; +enum drm_exynos_ipp_state state; +}; + +/* +* A structure of buffer information. +* +* @file: handle of file. +* @gem_handle: Y, Cb, Cr each gem handle. +* @base: Y, Cb, Cr each planar address. +*/ +struct drm_exynos_ipp_buf_info { +struct drm_file *file; +unsigned int gem_handle[EXYNOS_DRM_PLANAR_MAX ]; +dma_addr_t base[EXYNOS_DRM_PLANAR_MAX ]; +}; + +/* +* A structure of wb setting infomation. +* +* @enable: enable flag for wb. +* @refresh: HZ of the refresh rate. +*/ +struct drm_exynos_ipp_set_wb { +__u32 enable; +__u32 refresh; +}; + +/* +* A structure of event work information. +* +* @work: work structure. +* @ippdrv: current work ippdrv. +* @buf_id: id of src, dst buffer. +*/ +struct drm_exynos_ipp_event_work { +struct work_struct work; +struct exynos_drm_ippdrv *ippdrv; +u32 buf_id[EXYNOS_DRM_OPS_MAX ]; +}; + +/* +* A structure of source,destination operations. +* +* @set_fmt: set format of image. +* @set_transf: set transform(rotations, flip). +* @set_size: set size of region. +* @set_addr: set address for dma. drivers/gpu/drm/exynos/exynos_drm_ipp.h
Quoted 10 lines
drivers/gpu/drm/exynos/exynos_drm_ipp.h new file +10
-0+*/ +struct exynos_drm_ipp_ops { +int (*set_fmt)(struct device *dev,u32 fmt); +int (*set_transf)(struct device *dev, +enum drm_exynos_degree degree, +enum drm_exynos_flip flip); +int (*set_size)(struct device *dev,int swap, +struct drm_exynos_pos *pos,struct drm_exynos_sz *sz); +int (*set_addr)(struct device *dev, + struct drm_exynos_ipp_buf_info *buf_info, u32
buf_id,Quoted 37 lines
drivers/gpu/drm/exynos/exynos_drm_ipp.h new file +37
-0+ enum drm_exynos_ipp_buf_type buf_type); +}; + +/* +* A structure of ipp driver. +* +* @drv_list: list head for registed sub driver information. +* @parent_dev: parent device information. +* @dev: platform device. +* @drm_dev: drm device. +* @ipp_id: id of ipp driver. +* @dedicated: dedicated ipp device. +* @ops: source, destination operations. +* @event_workq: event work queue. +* @cmd: current command information. +* @cmd_list: list head for command information. +* @prop_list: property informations of current ipp driver. +* @check_property: check property about format, size, buffer. +* @reset: reset ipp block. +* @start: ipp each device start. +* @stop: ipp each device stop. +* @sched_event: work schedule handler. +*/ +struct exynos_drm_ippdrv { +struct list_head drv_list; +struct device *parent_dev; +struct device *dev; +struct drm_device *drm_dev; +u32 ipp_id; +bool dedicated; +struct exynos_drm_ipp_ops *ops[EXYNOS_DRM_OPS_MAX ]; +struct workqueue_struct *event_workq; +struct drm_exynos_ipp_cmd_node *cmd; +struct list_head cmd_list; +struct drm_exynos_ipp_prop_list *prop_list; + + int (*check_property)(struct device *dev,drivers/gpu/drm/exynos/exynos_drm_ipp.h
Quoted 10 lines
drivers/gpu/drm/exynos/exynos_drm_ipp.h new file +10
-0+ struct drm_exynos_ipp_property *property); +int (*reset)(struct device *dev); +int (*start)(struct device *dev,enum drm_exynos_ipp_cmd cmd); +void (*stop)(struct device *dev,enum drm_exynos_ipp_cmd cmd); +void (*sched_event)(struct work_struct *work); +}; + +#ifdef CONFIG_DRM_EXYNOS_IPP +extern int exynos_drm_ippdrv_register (struct exynos_drm_ippdrv *ippdrv); +extern int exynos_drm_ippdrv_unregister(struct exynos_drm_ippdrv*ippdrv);
drivers/gpu/drm/exynos/exynos_drm_ipp.h
Quoted 10 lines
+extern int exynos_drm_ipp_get_property(struct
drm_device*drm_dev, void *data,drivers/gpu/drm/exynos/exynos_drm_ipp.h new file +2
-0+ struct drm_file *file); +extern int exynos_drm_ipp_set_property(struct drm_device *drm_dev, void*data,
drivers/gpu/drm/exynos/exynos_drm_ipp.h new file +2
-0+ struct drm_file *file); +extern int exynos_drm_ipp_queue_buf(struct drm_device *drm_dev, void*data,
drivers/gpu/drm/exynos/exynos_drm_ipp.h new file +2
-0+ struct drm_file *file); +extern int exynos_drm_ipp_cmd_ctrl(struct drm_device *drm_dev, void*data,
Quoted 255 lines
drivers/gpu/drm/exynos/exynos_drm_ipp.h new file +9
-0+ struct drm_file *file); +extern int exynos_drm_ippnb_register (struct notifier_block *nb); +extern int exynos_drm_ippnb_unregister (struct notifier_block *nb); +extern int exynos_drm_ippnb_send_event (unsigned long val,void *v); +extern void ipp_sched_cmd (struct work_struct *work); +extern void ipp_sched_event (struct work_struct *work); + +#else +static inline int exynos_drm_ippdrv_register(struct exynos_drm_ippdrv*ippdrv)
drivers/gpu/drm/exynos/exynos_drm_ipp.h new file +5
-0+{ +return -ENODEV ; +} + +static inline int exynos_drm_ippdrv_unregister(struct exynos_drm_ippdrv*ippdrv)
drivers/gpu/drm/exynos/exynos_drm_ipp.h new file +50
-0+{ +return -ENODEV ; +} + +static inline int exynos_drm_ipp_get_property (struct drm_device *drm_dev, +void *data, +struct drm_file *file_priv) +{ +return -ENOTTY ; +} + +static inline int exynos_drm_ipp_set_property (struct drm_device *drm_dev, +void *data, +struct drm_file *file_priv) +{ +return -ENOTTY ; +} + +static inline int exynos_drm_ipp_queue_buf (struct drm_device *drm_dev, +void *data, +struct drm_file *file) +{ +return -ENOTTY ; +} + +static inline int exynos_drm_ipp_cmd_ctrl (struct drm_device *drm_dev, +void *data, +struct drm_file *file) +{ +return -ENOTTY ; +} + +static inline int exynos_drm_ippnb_register (struct notifier_block *nb) +{ +return -ENODEV ; +} + +static inline int exynos_drm_ippnb_unregister (struct notifier_block *nb) +{ +return -ENODEV ; +} + +static inline int exynos_drm_ippnb_send_event (unsigned long val,void *v) +{ +return -ENOTTY ; +} +#endif + +#endif /* _EXYNOS_DRM_IPP_H_ */ +include/uapi/drm/exynos_drm.h +169
-0@@ -154,6 +154,169 @@ struct drm_exynos_g2d_exec {__u64 async; }; +enum drm_exynos_ops_id { +EXYNOS_DRM_OPS_SRC , +EXYNOS_DRM_OPS_DST , +EXYNOS_DRM_OPS_MAX , +}; + +struct drm_exynos_sz { +__u32 hsize; +__u32 vsize; +}; + +struct drm_exynos_pos { +__u32 x; +__u32 y; +__u32 w; +__u32 h; +}; + +enum drm_exynos_flip { +EXYNOS_DRM_FLIP_NONE = (0 <<0 ), +EXYNOS_DRM_FLIP_VERTICAL = (1 <<0 ), +EXYNOS_DRM_FLIP_HORIZONTAL = (1 <<1 ), +}; + +enum drm_exynos_degree { +EXYNOS_DRM_DEGREE_0 , +EXYNOS_DRM_DEGREE_90 , +EXYNOS_DRM_DEGREE_180 , +EXYNOS_DRM_DEGREE_270 , +}; + +enum drm_exynos_planer { +EXYNOS_DRM_PLANAR_Y , +EXYNOS_DRM_PLANAR_CB , +EXYNOS_DRM_PLANAR_CR , +EXYNOS_DRM_PLANAR_MAX , +}; + +/** +* A structure for ipp supported property list. +* +* @version: version of this structure. +* @ipp_id: id of ipp driver. +* @count: count of ipp driver. +* @writeback: flag of writeback supporting. +* @flip: flag of flip supporting. +* @degree: flag of degree information. +* @csc: flag of csc supporting. +* @crop: flag of crop supporting. +* @scale: flag of scale supporting. +* @refresh_min: min hz of refresh. +* @refresh_max: max hz of refresh. +* @crop_min: crop min resolution. +* @crop_max: crop max resolution. +* @scale_min: scale min resolution. +* @scale_max: scale max resolution. +*/ +struct drm_exynos_ipp_prop_list { +__u32 version; +__u32 ipp_id; +__u32 count; +__u32 writeback; +__u32 flip; +__u32 degree; +__u32 csc; +__u32 crop; +__u32 scale; +__u32 refresh_min; +__u32 refresh_max; +__u32 reserved; +struct drm_exynos_sz crop_min; +struct drm_exynos_sz crop_max; +struct drm_exynos_sz scale_min; +struct drm_exynos_sz scale_max; +}; + +/** +* A structure for ipp config. +* +* @ops_id: property of operation directions. +* @flip: property of mirror, flip. +* @degree: property of rotation degree. +* @fmt: property of image format. +* @sz: property of image size. +* @pos: property of image position(src-cropped,dst-scaler). +*/ +struct drm_exynos_ipp_config { +enum drm_exynos_ops_id ops_id; +enum drm_exynos_flip flip; +enum drm_exynos_degree degree; +__u32 fmt; +struct drm_exynos_sz sz; +struct drm_exynos_pos pos; +}; + +enum drm_exynos_ipp_cmd { +IPP_CMD_NONE , +IPP_CMD_M2M , +IPP_CMD_WB , +IPP_CMD_OUTPUT , +IPP_CMD_MAX , +}; + +/** +* A structure for ipp property. +* +* @config: source, destination config. +* @cmd: definition of command. +* @ipp_id: id of ipp driver. +* @prop_id: id of property. +*/ +struct drm_exynos_ipp_property { +struct drm_exynos_ipp_config config[EXYNOS_DRM_OPS_MAX ]; +enum drm_exynos_ipp_cmd cmd; +__u32 ipp_id; +__u32 prop_id; +__u32 reserved; +}; + +enum drm_exynos_ipp_buf_type { +IPP_BUF_ENQUEUE , +IPP_BUF_DEQUEUE , +}; + +/** +* A structure for ipp buffer operations. +* +* @ops_id: operation directions. +* @buf_type: definition of buffer. +* @prop_id: id of property. +* @buf_id: id of buffer. +* @handle: Y, Cb, Cr each planar handle. +* @user_data: user data. +*/ +struct drm_exynos_ipp_queue_buf { +enum drm_exynos_ops_id ops_id; +enum drm_exynos_ipp_buf_type buf_type; +__u32 prop_id; +__u32 buf_id; +__u32 handle[EXYNOS_DRM_PLANAR_MAX ]; +__u32 reserved; +__u64 user_data; +}; + +enum drm_exynos_ipp_ctrl { +IPP_CTRL_PLAY , +IPP_CTRL_STOP , +IPP_CTRL_PAUSE , +IPP_CTRL_RESUME , +IPP_CTRL_MAX , +}; + +/** +* A structure for ipp start/stop operations. +* +* @prop_id: id of property. +* @ctrl: definition of control. +*/ +struct drm_exynos_ipp_cmd_ctrl { +__u32 prop_id; +enum drm_exynos_ipp_ctrl ctrl; +}; +#define DRM_EXYNOS_GEM_CREATE 0x00#define DRM_EXYNOS_GEM_MAP_OFFSET 0x01#define DRM_EXYNOS_GEM_MMAP 0x02@@ -166,6 +329,12 @@ struct drm_exynos_g2d_exec {#define DRM_EXYNOS_G2D_SET_CMDLIST 0x21#define DRM_EXYNOS_G2D_EXEC 0x22 +/* IPP - Image Post Processing */ +#define DRM_EXYNOS_IPP_GET_PROPERTY 0x30 +#define DRM_EXYNOS_IPP_SET_PROPERTY 0x31 +#define DRM_EXYNOS_IPP_QUEUE_BUF 0x32 +#define DRM_EXYNOS_IPP_CMD_CTRL 0x33 +#define DRM_IOCTL_EXYNOS_GEM_CREATE DRM_IOWR(DRM_COMMAND_BASE + \ DRM_EXYNOS_GEM_CREATE, struct drm_exynos_gem_create)include/uapi/drm/exynos_drm.h struct drm_exynos_g2d_exec { · line 363
Quoted 7 lines
include/uapi/drm/exynos_drm.h +2
-0@@ -188,8 +357,18 @@ struct drm_exynos_g2d_exec {#define DRM_IOCTL_EXYNOS_G2D_EXEC DRM_IOWR(DRM_COMMAND_BASE + \ DRM_EXYNOS_G2D_EXEC, struct drm_exynos_g2d_exec) +#define DRM_IOCTL_EXYNOS_IPP_GET_PROPERTY DRM_IOWR(DRM_COMMAND_BASE + \ +DRM_EXYNOS_IPP_GET_PROPERTY , struct
drm_exynos_ipp_prop_list)include/uapi/drm/exynos_drm.h struct drm_exynos_g2d_exec { · line 367
Quoted 4 lines
include/uapi/drm/exynos_drm.h +3
-0+#define DRM_IOCTL_EXYNOS_IPP_SET_PROPERTY DRM_IOWR(DRM_COMMAND_BASE + \ + DRM_EXYNOS_IPP_SET_PROPERTY, struct drm_exynos_ipp_property) +#define DRM_IOCTL_EXYNOS_IPP_QUEUE_BUF DRM_IOWR(DRM_COMMAND_BASE +\
include/uapi/drm/exynos_drm.h struct drm_exynos_g2d_exec { · line 369
Quoted 2 lines
include/uapi/drm/exynos_drm.h +2
-0+ DRM_EXYNOS_IPP_QUEUE_BUF, struct drm_exynos_ipp_queue_buf) +#define DRM_IOCTL_EXYNOS_IPP_CMD_CTRL DRM_IOWR(DRM_COMMAND_BASE +
Quoted 26 lines
include/uapi/drm/exynos_drm.h +13
-1\ + DRM_EXYNOS_IPP_CMD_CTRL, struct drm_exynos_ipp_cmd_ctrl) +/* EXYNOS specific events */ #define DRM_EXYNOS_G2D_EVENT 0x80000000 +#define DRM_EXYNOS_IPP_EVENT 0x80000001struct drm_exynos_g2d_event {struct drm_event base;@@ -200,4 +379,14 @@ struct drm_exynos_g2d_event { __u32 reserved; }; +struct drm_exynos_ipp_event { +struct drm_event base; +__u64 user_data; +__u32 tv_sec; +__u32 tv_usec; +__u32 prop_id; +__u32 reserved; +__u32 buf_id[EXYNOS_DRM_OPS_MAX ]; +}; +#endif /* _UAPI_EXYNOS_DRM_H_ */ --1.7.0.4
RFC 2/4 drm/exynos: add fimc ipp driver
In reply to Eunchul KimFIMC is stand for Fully Interfactive Mobile Camera and
supports image scaler/rotator/crop/flip/csc and input/output DMA operations. input DMA reads image data from the memory.
output DMA writes image data to memory.
FIMC supports image rotation and image effect functions.
also supports writeback and display output operations.
--- drivers/gpu/drm/exynos/Kconfig | 6 + drivers/gpu/drm/exynos/Makefile | 1 + drivers/gpu/drm/exynos/exynos_drm_drv.c | 15 + drivers/gpu/drm/exynos/exynos_drm_drv.h | 1 + drivers/gpu/drm/exynos/exynos_drm_fimc.c | 2041 ++++++++++++++++++++++++++++++ drivers/gpu/drm/exynos/exynos_drm_fimc.h | 35 + drivers/gpu/drm/exynos/regs-fimc.h | 669 ++++++++++ include/drm/exynos_drm.h | 33 + 8 files changed, 2801 insertions(+), 0 deletions(-) create mode 100644 drivers/gpu/drm/exynos/exynos_drm_fimc.c create mode 100644 drivers/gpu/drm/exynos/exynos_drm_fimc.h create mode 100644 drivers/gpu/drm/exynos/regs-fimc.h
drivers/gpu/drm/exynos/Kconfig +6 -0
@@ -45,3 +45,9 @@ config DRM_EXYNOS_IPP depends on DRM_EXYNOS help Choose this option if you want to use IPP feature for DRM. + +config DRM_EXYNOS_FIMC + bool "Exynos DRM FIMC" + depends on DRM_EXYNOS_IPP + help + Choose this option if you want to use Exynos FIMC for DRM.
drivers/gpu/drm/exynos/Makefile +1 -0
@@ -16,5 +16,6 @@ exynosdrm-$(CONFIG_DRM_EXYNOS_HDMI) += exynos_hdmi.o exynos_mixer.o \ exynosdrm-$(CONFIG_DRM_EXYNOS_VIDI) += exynos_drm_vidi.o exynosdrm-$(CONFIG_DRM_EXYNOS_G2D) += exynos_drm_g2d.o exynosdrm-$(CONFIG_DRM_EXYNOS_IPP) += exynos_drm_ipp.o +exynosdrm-$(CONFIG_DRM_EXYNOS_FIMC) += exynos_drm_fimc.o obj-$(CONFIG_DRM_EXYNOS) += exynosdrm.o
drivers/gpu/drm/exynos/exynos_drm_drv.c +15 -0
@@ -355,6 +355,12 @@ static int __init exynos_drm_init(void) goto out_g2d;#endif +#ifdef CONFIG_DRM_EXYNOS_FIMC + ret =platform_driver_register (&fimc_driver); +if (ret <0 ) + goto out_fimc; +#endif +#ifdef CONFIG_DRM_EXYNOS_IPP ret =platform_driver_register (&ipp_driver);if (ret <0 )
@@ -383,6 +389,11 @@ out_drm: out_ipp:#endif +#ifdef CONFIG_DRM_EXYNOS_FIMC +platform_driver_unregister (&fimc_driver); +out_fimc: +#endif +#ifdef CONFIG_DRM_EXYNOS_G2D platform_driver_unregister (&g2d_driver); out_g2d:
@@ -423,6 +434,10 @@ static void __exit exynos_drm_exit(void)platform_driver_unregister (&ipp_driver);#endif +#ifdef CONFIG_DRM_EXYNOS_FIMC +platform_driver_unregister (&fimc_driver); +#endif +#ifdef CONFIG_DRM_EXYNOS_G2D platform_driver_unregister (&g2d_driver);#endif
drivers/gpu/drm/exynos/exynos_drm_drv.h +1 -0
@@ -341,5 +341,6 @@ extern struct platform_driver mixer_driver;extern struct platform_driver exynos_drm_common_hdmi_driver;extern struct platform_driver vidi_driver;extern struct platform_driver g2d_driver; +extern struct platform_driver fimc_driver;extern struct platform_driver ipp_driver;#endif
drivers/gpu/drm/exynos/exynos_drm_fimc.c new file +2041 -0
2,041 lines not on this page · raw message
drivers/gpu/drm/exynos/exynos_drm_fimc.h new file +35 -0
@@ -0,0 +1,35 @@ +/* +* Copyright (c) 2012 Samsung Electronics Co., Ltd. +* +* Authors: +* Eunchul Kim <[email protected]> +* Jinyoung Jeon <[email protected]> +* Sangmin Lee <[email protected]> +* +* Permission is hereby granted, free of charge, to any person obtaining a +* copy of this software and associated documentation files (the "Software"), +* to deal in the Software without restriction, including without limitation +* the rights to use, copy, modify, merge, publish, distribute, sublicense, +* and/or sell copies of the Software, and to permit persons to whom the +* Software is furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice (including the next +* paragraph) shall be included in all copies or substantial portions of the +* Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +* VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR +* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +* OTHER DEALINGS IN THE SOFTWARE. +*/ + +#ifndef _EXYNOS_DRM_FIMC_H_ +#define _EXYNOS_DRM_FIMC_H_ + +/* ToDo */ + +#endif /* _EXYNOS_DRM_FIMC_H_ */ +
drivers/gpu/drm/exynos/regs-fimc.h new file +669 -0
669 lines not on this page · raw message
include/drm/exynos_drm.h +33 -0
@@ -85,4 +85,37 @@ struct exynos_drm_hdmi_pdata { int (*get_hpd)(void); }; +/** +* Platform Specific Structure for DRM based FIMC. +* +* @inv_pclk: if set 1. invert pixel clock +* @inv_vsync: if set 1. invert vsync signal for wb +* @inv_href: if set 1. invert href signal +* @inv_hsync: if set 1. invert hsync signal for wb +*/ +struct exynos_drm_fimc_pol { +unsigned int inv_pclk; +unsigned int inv_vsync; +unsigned int inv_href; +unsigned int inv_hsync; +}; + +enum exynos_drm_fimc_ver { +FIMC_EXYNOS_4210 , +FIMC_EXYNOS_4212 , +FIMC_EXYNOS_4412 , +FIMC_EXYNOS_4412_R2 , +}; + +/** +* Platform Specific Structure for DRM based FIMC. +* +* @pol: current hardware block polarity settings. +* @ver: current hardware block version. +*/ +struct exynos_drm_fimc_pdata { +struct exynos_drm_fimc_pol pol; +enum exynos_drm_fimc_ver ver; +}; +#endif /* _EXYNOS_DRM_H_ */
Signature · 1 line
1.7.0.4
김승우
maintainerRe: [RFC 2/4] drm/exynos: add fimc ipp driver
Hi Eunchul,
IMHO, each function for source and destination has quite similar routine and it seems that there are some redundant code. I'm not sure these duplicated code can be removed with mergeing similar part.
Some comments are below.
Quoted 22 lines · Eunchul Kim
FIMC is stand for Fully Interfactive Mobile Camera and
supports image scaler/rotator/crop/flip/csc and input/output DMA operations. input DMA reads image data from the memory.
output DMA writes image data to memory.
FIMC supports image rotation and image effect functions.
also supports writeback and display output operations.Signed-off-by Eunchul Kim <[email protected]>Signed-off-by Jinyoung Jeon <[email protected]>--- drivers/gpu/drm/exynos/Kconfig | 6 + drivers/gpu/drm/exynos/Makefile | 1 + drivers/gpu/drm/exynos/exynos_drm_drv.c | 15 + drivers/gpu/drm/exynos/exynos_drm_drv.h | 1 + drivers/gpu/drm/exynos/exynos_drm_fimc.c | 2041 ++++++++++++++++++++++++++++++ drivers/gpu/drm/exynos/exynos_drm_fimc.h | 35 + drivers/gpu/drm/exynos/regs-fimc.h | 669 ++++++++++ include/drm/exynos_drm.h | 33 + 8 files changed, 2801 insertions(+), 0 deletions(-) create mode 100644 drivers/gpu/drm/exynos/exynos_drm_fimc.c create mode 100644 drivers/gpu/drm/exynos/exynos_drm_fimc.h create mode 100644 drivers/gpu/drm/exynos/regs-fimc.h
<snip>
Quoted 479 lines
drivers/gpu/drm/exynos/exynos_drm_fimc.c new file +473
-0@@ -0,0 +1,2041 @@ +/* +* Copyright (C) 2012 Samsung Electronics Co.Ltd +* Authors: +* Eunchul Kim <[email protected]> +* Jinyoung Jeon <[email protected]> +* Sangmin Lee <[email protected]> +* +* This program is free software; you can redistribute it and/or modify it +* under the terms of the GNU General Public License as published by the +* Free Software Foundation; either version 2 of the License, or (at your +* option) any later version. +* +*/ +#include <linux/kernel.h> +#include <linux/module.h> +#include <linux/platform_device.h> +#include <linux/clk.h> +#include <linux/pm_runtime.h> +#include <plat/map-base.h> + +#include <drm/drmP.h> +#include <drm/exynos_drm.h> +#include "regs-fimc.h" +#include "exynos_drm_drv.h" +#include "exynos_drm_gem.h" +#include "exynos_drm_ipp.h" +#include "exynos_drm_fimc.h" + +/* +* FIMC is stand for Fully Interactive Mobile Camera and +* supports image scaler/rotator and input/output DMA operations. +* input DMA reads image data from the memory. +* output DMA writes image data to memory. +* FIMC supports image rotation and image effect functions. +*/ + +#define FIMC_MAX_DEVS 4 +#define FIMC_MAX_SRC 2 +#define FIMC_MAX_DST 32 +#define FIMC_CLK_RATE 166750000 +#define FIMC_CLK_RATE_R2 180000000 +#define FIMC_BUF_STOP 1 +#define FIMC_BUF_START 2 +#define FIMC_REG_SZ 32 +#define FIMC_WIDTH_ITU_709 1280 + +#define get_fimc_context (dev) platform_get_drvdata(to_platform_device(dev)) +#define get_ctx_from_ippdrv (ippdrv) container_of(ippdrv,\ + struct fimc_context, ippdrv); +#define fimc_read (offset) readl(ctx->regs + (offset)); +#define fimc_write (cfg, offset) writel(cfg, ctx->regs + (offset)); + +enum fimc_wb { +FIMC_WB_NONE , +FIMC_WB_A , +FIMC_WB_B , +}; + +/* +* A structure of scaler. +* +* @range: narrow, wide. +* @bypass: unused scaler path. +* @up_h: horizontal scale up. +* @up_v: vertical scale up. +* @hratio: horizontal ratio. +* @vratio: vertical ratio. +*/ +struct fimc_scaler { +bool range; +bool bypass; +bool up_h; +bool up_v; +u32 hratio; +u32 vratio; +}; + +/* +* A structure of scaler capability. +* +* find user manual table 43-1. +* @in_hori: scaler input horizontal size. +* @bypass: scaler bypass mode. +* @dst_h_wo_rot: target horizontal size without output rotation. +* @dst_h_rot: target horizontal size with output rotation. +* @rl_w_wo_rot: real width without input rotation. +* @rl_h_rot: real height without output rotation. +*/ +struct fimc_capability { +/* scaler */ +u32 in_hori; +u32 bypass; +/* output rotator */ +u32 dst_h_wo_rot; +u32 dst_h_rot; +/* input rotator */ +u32 rl_w_wo_rot; +u32 rl_h_rot; +}; + +/* +* A structure of fimc context. +* +* @ippdrv: prepare initialization using ippdrv. +* @regs_res: register resources. +* @regs: memory mapped io registers. +* @lock: locking of operations. +* @sclk_fimc_clk: fimc source clock. +* @fimc_clk: fimc clock. +* @wb_clk: writeback a clock. +* @wb_b_clk: writeback b clock. +* @sc: scaler infomations. +* @capa: scaler capability. +* @odr: ordering of YUV. +* @ver: fimc version. +* @pol: porarity of writeback. +* @id: fimc id. +* @irq: irq number. +* @suspended: qos operations. +*/ +struct fimc_context { +struct exynos_drm_ippdrv ippdrv; +struct resource *regs_res; +void __iomem *regs; +spinlock_t lock; +struct clk *sclk_fimc_clk; +struct clk *fimc_clk; +struct clk *wb_clk; +struct clk *wb_b_clk; +struct fimc_scaler sc; +struct fimc_capability *capa; +enum exynos_drm_fimc_ver ver; +struct exynos_drm_fimc_pol pol; +int id; +int irq; +bool suspended; +}; + +struct fimc_capability fimc51_capa[FIMC_MAX_DEVS ] = { + { + .in_hori =4224 , + .bypass =8192 , + .dst_h_wo_rot =4224 , + .dst_h_rot =1920 , + .rl_w_wo_rot =8192 , + .rl_h_rot =1920 , + }, { + .in_hori =4224 , + .bypass =8192 , + .dst_h_wo_rot =4224 , + .dst_h_rot =1920 , + .rl_w_wo_rot =8192 , + .rl_h_rot =1920 , + }, { + .in_hori =4224 , + .bypass =8192 , + .dst_h_wo_rot =4224 , + .dst_h_rot =1920 , + .rl_w_wo_rot =8192 , + .rl_h_rot =1920 , + }, { + .in_hori =1920 , + .bypass =8192 , + .dst_h_wo_rot =1920 , + .dst_h_rot =1366 , + .rl_w_wo_rot =8192 , + .rl_h_rot =1366 , + }, +}; + +static void fimc_sw_reset (struct fimc_context *ctx,bool pattern) +{ +u32 cfg; + +DRM_DEBUG_KMS ("%s:pattern[%d]\n" , __func__, pattern); + + cfg =fimc_read (EXYNOS_CISRCFMT ); + cfg |=EXYNOS_CISRCFMT_ITU601_8BIT ; +if (pattern) + cfg |=EXYNOS_CIGCTRL_TESTPATTERN_COLOR_BAR ; + +fimc_write (cfg,EXYNOS_CISRCFMT ); + +/* s/w reset */ + cfg =fimc_read (EXYNOS_CIGCTRL ); + cfg |= (EXYNOS_CIGCTRL_SWRST ); +fimc_write (cfg,EXYNOS_CIGCTRL ); + +/* s/w reset complete */ + cfg =fimc_read (EXYNOS_CIGCTRL ); + cfg &= ~EXYNOS_CIGCTRL_SWRST ; +fimc_write (cfg,EXYNOS_CIGCTRL ); + +/* reset sequence */ +fimc_write (0x0 ,EXYNOS_CIFCNTSEQ ); +} + +static void fimc_set_camblk_fimd0_wb (struct fimc_context *ctx) +{ +u32 camblk_cfg; + +DRM_DEBUG_KMS ("%s\n" , __func__); + + camblk_cfg =readl (SYSREG_CAMERA_BLK ); + camblk_cfg &= ~(SYSREG_FIMD0WB_DEST_MASK ); + camblk_cfg |= ctx->id << (SYSREG_FIMD0WB_DEST_SHIFT ); + +writel (camblk_cfg,SYSREG_CAMERA_BLK ); +} + +static void fimc_set_type_ctrl (struct fimc_context *ctx,enum fimc_wb wb) +{ +u32 cfg; + +DRM_DEBUG_KMS ("%s:wb[%d]\n" , __func__, wb); + + cfg =fimc_read (EXYNOS_CIGCTRL ); + cfg &= ~(EXYNOS_CIGCTRL_TESTPATTERN_MASK | +EXYNOS_CIGCTRL_SELCAM_ITU_MASK | +EXYNOS_CIGCTRL_SELCAM_MIPI_MASK | +EXYNOS_CIGCTRL_SELCAM_FIMC_MASK | +EXYNOS_CIGCTRL_SELWB_CAMIF_MASK | +EXYNOS_CIGCTRL_SELWRITEBACK_MASK ); + +switch (wb) { +case FIMC_WB_A : + cfg |= (EXYNOS_CIGCTRL_SELWRITEBACK_A | +EXYNOS_CIGCTRL_SELWB_CAMIF_WRITEBACK ); +break ; +case FIMC_WB_B : + cfg |= (EXYNOS_CIGCTRL_SELWRITEBACK_B | +EXYNOS_CIGCTRL_SELWB_CAMIF_WRITEBACK ); +break ; +case FIMC_WB_NONE : +default : + cfg |= (EXYNOS_CIGCTRL_SELCAM_ITU_A | +EXYNOS_CIGCTRL_SELWRITEBACK_A | +EXYNOS_CIGCTRL_SELCAM_MIPI_A | +EXYNOS_CIGCTRL_SELCAM_FIMC_ITU ); +break ; + } + +fimc_write (cfg,EXYNOS_CIGCTRL ); +} + +static void fimc_set_polarity (struct fimc_context *ctx, +struct exynos_drm_fimc_pol *pol) +{ +u32 cfg; + +DRM_DEBUG_KMS ("%s:inv_pclk[%d]inv_vsync[%d]\n" , + __func__, pol->inv_pclk, pol->inv_vsync); +DRM_DEBUG_KMS ("%s:inv_href[%d]inv_hsync[%d]\n" , + __func__, pol->inv_href, pol->inv_hsync); + + cfg =fimc_read (EXYNOS_CIGCTRL ); + cfg &= ~(EXYNOS_CIGCTRL_INVPOLPCLK |EXYNOS_CIGCTRL_INVPOLVSYNC | +EXYNOS_CIGCTRL_INVPOLHREF |EXYNOS_CIGCTRL_INVPOLHSYNC ); + +if (pol->inv_pclk) + cfg |=EXYNOS_CIGCTRL_INVPOLPCLK ; +if (pol->inv_vsync) + cfg |=EXYNOS_CIGCTRL_INVPOLVSYNC ; +if (pol->inv_href) + cfg |=EXYNOS_CIGCTRL_INVPOLHREF ; +if (pol->inv_hsync) + cfg |=EXYNOS_CIGCTRL_INVPOLHSYNC ; + +fimc_write (cfg,EXYNOS_CIGCTRL ); +} + +static void fimc_handle_jpeg (struct fimc_context *ctx,bool enable) +{ +u32 cfg; + +DRM_DEBUG_KMS ("%s:enable[%d]\n" , __func__, enable); + + cfg =fimc_read (EXYNOS_CIGCTRL ); +if (enable) + cfg |=EXYNOS_CIGCTRL_CAM_JPEG ; +else + cfg &= ~EXYNOS_CIGCTRL_CAM_JPEG ; + +fimc_write (cfg,EXYNOS_CIGCTRL ); +} + +static void fimc_handle_irq (struct fimc_context *ctx,bool enable, +bool overflow,bool level) +{ +u32 cfg; + +DRM_DEBUG_KMS ("%s:enable[%d]overflow[%d]level[%d]\n" , __func__, + enable, overflow, level); + + cfg =fimc_read (EXYNOS_CIGCTRL ); +if (enable) { + cfg &= ~(EXYNOS_CIGCTRL_IRQ_OVFEN |EXYNOS_CIGCTRL_IRQ_LEVEL ); + cfg |=EXYNOS_CIGCTRL_IRQ_ENABLE ; +if (overflow) + cfg |=EXYNOS_CIGCTRL_IRQ_OVFEN ; +if (level) + cfg |=EXYNOS_CIGCTRL_IRQ_LEVEL ; + }else + cfg &= ~(EXYNOS_CIGCTRL_IRQ_OVFEN |EXYNOS_CIGCTRL_IRQ_ENABLE ); + +fimc_write (cfg,EXYNOS_CIGCTRL ); +} + +static void fimc_clear_irq (struct fimc_context *ctx) +{ +u32 cfg; + +DRM_DEBUG_KMS ("%s\n" , __func__); + + cfg =fimc_read (EXYNOS_CIGCTRL ); + cfg |=EXYNOS_CIGCTRL_IRQ_CLR ; +fimc_write (cfg,EXYNOS_CIGCTRL ); +} + +static bool fimc_check_ovf (struct fimc_context *ctx) +{ +struct exynos_drm_ippdrv *ippdrv = &ctx->ippdrv; +u32 cfg, status, flag; + + status =fimc_read (EXYNOS_CISTATUS ); + flag =EXYNOS_CISTATUS_OVFIY |EXYNOS_CISTATUS_OVFICB | +EXYNOS_CISTATUS_OVFICR ; + +DRM_DEBUG_KMS ("%s:flag[0x%x]\n" , __func__, flag); + +if (status & flag) { + cfg =fimc_read (EXYNOS_CIWDOFST ); + cfg |= (EXYNOS_CIWDOFST_CLROVFIY |EXYNOS_CIWDOFST_CLROVFICB | +EXYNOS_CIWDOFST_CLROVFICR ); + +fimc_write (cfg,EXYNOS_CIWDOFST ); + + cfg =fimc_read (EXYNOS_CIWDOFST ); + cfg &= ~(EXYNOS_CIWDOFST_CLROVFIY |EXYNOS_CIWDOFST_CLROVFICB | +EXYNOS_CIWDOFST_CLROVFICR ); + +fimc_write (cfg,EXYNOS_CIWDOFST ); + +dev_err (ippdrv->dev,"occured overflow at %d, status 0x%x.\n" , + ctx->id, status); +return true; + } + +return false; +} + +static bool fimc_check_frame_end (struct fimc_context *ctx) +{ +u32 cfg; + + cfg =fimc_read (EXYNOS_CISTATUS ); + +DRM_DEBUG_KMS ("%s:cfg[0x%x]\n" , __func__, cfg); + +if (!(cfg &EXYNOS_CISTATUS_FRAMEEND )) +return false; + + cfg &= ~(EXYNOS_CISTATUS_FRAMEEND ); +fimc_write (cfg,EXYNOS_CISTATUS ); + +return true; +} + +static int fimc_get_buf_id (struct fimc_context *ctx) +{ +u32 cfg; +int frame_cnt, buf_id; + +DRM_DEBUG_KMS ("%s\n" , __func__); + + cfg =fimc_read (EXYNOS_CISTATUS2 ); + frame_cnt =EXYNOS_CISTATUS2_GET_FRAMECOUNT_BEFORE (cfg); + +if (frame_cnt ==0 ) + frame_cnt =EXYNOS_CISTATUS2_GET_FRAMECOUNT_PRESENT (cfg); + +DRM_DEBUG_KMS ("%s:present[%d]before[%d]\n" , __func__, +EXYNOS_CISTATUS2_GET_FRAMECOUNT_PRESENT (cfg), +EXYNOS_CISTATUS2_GET_FRAMECOUNT_BEFORE (cfg)); + +if (frame_cnt ==0 ) { +DRM_ERROR ("failed to get frame count.\n" ); +return -EIO ; + } + + buf_id = frame_cnt -1 ; +DRM_DEBUG_KMS ("%s:buf_id[%d]\n" , __func__, buf_id); + +return buf_id; +} + +static void fimc_handle_lastend (struct fimc_context *ctx,bool enable) +{ +u32 cfg; + +DRM_DEBUG_KMS ("%s:enable[%d]\n" , __func__, enable); + + cfg =fimc_read (EXYNOS_CIOCTRL ); +if (enable) + cfg |=EXYNOS_CIOCTRL_LASTENDEN ; +else + cfg &= ~EXYNOS_CIOCTRL_LASTENDEN ; + +fimc_write (cfg,EXYNOS_CIOCTRL ); +} + + +static int fimc_src_set_fmt_order (struct fimc_context *ctx,u32 fmt) +{ +struct exynos_drm_ippdrv *ippdrv = &ctx->ippdrv; +u32 cfg; + +DRM_DEBUG_KMS ("%s:fmt[0x%x]\n" , __func__, fmt); + +/* RGB */ + cfg =fimc_read (EXYNOS_CISCCTRL ); + cfg &= ~EXYNOS_CISCCTRL_INRGB_FMT_RGB_MASK ; + +switch (fmt) { +case DRM_FORMAT_RGB565 : + cfg |=EXYNOS_CISCCTRL_INRGB_FMT_RGB565 ; +fimc_write (cfg,EXYNOS_CISCCTRL ); +return 0 ; +case DRM_FORMAT_RGB888 : +case DRM_FORMAT_XRGB8888 : + cfg |=EXYNOS_CISCCTRL_INRGB_FMT_RGB888 ; +fimc_write (cfg,EXYNOS_CISCCTRL ); +return 0 ; +default : +/* bypass */ +break ; + } + +/* YUV */ + cfg =fimc_read (EXYNOS_MSCTRL ); + cfg &= ~(EXYNOS_MSCTRL_ORDER2P_SHIFT_MASK | +EXYNOS_MSCTRL_C_INT_IN_2PLANE | +EXYNOS_MSCTRL_ORDER422_YCBYCR ); + +switch (fmt) { +case DRM_FORMAT_YUYV : + cfg |=EXYNOS_MSCTRL_ORDER422_YCBYCR ; +break ; +case DRM_FORMAT_YVYU : + cfg |=EXYNOS_MSCTRL_ORDER422_YCRYCB ; +break ; +case DRM_FORMAT_UYVY : + cfg |=EXYNOS_MSCTRL_ORDER422_CBYCRY ; +break ; +case DRM_FORMAT_VYUY : +case DRM_FORMAT_YUV444 : + cfg |=EXYNOS_MSCTRL_ORDER422_CRYCBY ; +break ; +case DRM_FORMAT_NV21 : +case DRM_FORMAT_NV61 : + cfg |= (EXYNOS_MSCTRL_ORDER2P_LSB_CRCB | +EXYNOS_MSCTRL_C_INT_IN_2PLANE ); +break ; +case DRM_FORMAT_YUV422 : +case DRM_FORMAT_YUV420 : +case DRM_FORMAT_YVU420 : + cfg |=EXYNOS_MSCTRL_C_INT_IN_3PLANE ; +break ; +case DRM_FORMAT_NV12 : +case DRM_FORMAT_NV12MT : +case DRM_FORMAT_NV16 : + cfg |= (EXYNOS_MSCTRL_ORDER2P_LSB_CBCR | +EXYNOS_MSCTRL_C_INT_IN_2PLANE );
drivers/gpu/drm/exynos/exynos_drm_fimc.c line 483
Quoted 10 lines
drivers/gpu/drm/exynos/exynos_drm_fimc.c new file +10
-0+break ; +default : +dev_err (ippdrv->dev,"inavlid source yuv order 0x%x.\n" , fmt); +return -EINVAL ; + } + +fimc_write (cfg,EXYNOS_MSCTRL ); + +return 0 ; +}
This function is only called by fimc_src_set_fmt() and both functions have routine to check format. There are also accessing EXYNOS_MSCTRL. So done those routine at one merged function can be helpful.
Quoted 349 lines
drivers/gpu/drm/exynos/exynos_drm_fimc.c new file +349
-0+ +static int fimc_src_set_fmt (struct device *dev,u32 fmt) +{ +struct fimc_context *ctx =get_fimc_context (dev); +struct exynos_drm_ippdrv *ippdrv = &ctx->ippdrv; +u32 cfg; + +DRM_DEBUG_KMS ("%s:fmt[0x%x]\n" , __func__, fmt); + + cfg =fimc_read (EXYNOS_MSCTRL ); + cfg &= ~EXYNOS_MSCTRL_INFORMAT_RGB ; + +switch (fmt) { +case DRM_FORMAT_RGB565 : +case DRM_FORMAT_RGB888 : +case DRM_FORMAT_XRGB8888 : + cfg |=EXYNOS_MSCTRL_INFORMAT_RGB ; +break ; +case DRM_FORMAT_YUV444 : + cfg |=EXYNOS_MSCTRL_INFORMAT_YCBCR420 ; +break ; +case DRM_FORMAT_YUYV : +case DRM_FORMAT_YVYU : +case DRM_FORMAT_UYVY : +case DRM_FORMAT_VYUY : + cfg |=EXYNOS_MSCTRL_INFORMAT_YCBCR422_1PLANE ; +break ; +case DRM_FORMAT_NV16 : +case DRM_FORMAT_NV61 : +case DRM_FORMAT_YUV422 : + cfg |=EXYNOS_MSCTRL_INFORMAT_YCBCR422 ; +break ; +case DRM_FORMAT_YUV420 : +case DRM_FORMAT_YVU420 : +case DRM_FORMAT_NV12 : +case DRM_FORMAT_NV21 : +case DRM_FORMAT_NV12MT : + cfg |=EXYNOS_MSCTRL_INFORMAT_YCBCR420 ; +break ; +default : +dev_err (ippdrv->dev,"inavlid source format 0x%x.\n" , fmt); +return -EINVAL ; + } + +fimc_write (cfg,EXYNOS_MSCTRL ); + + cfg =fimc_read (EXYNOS_CIDMAPARAM ); + cfg &= ~EXYNOS_CIDMAPARAM_R_MODE_MASK ; + +if (fmt ==DRM_FORMAT_NV12MT ) + cfg |=EXYNOS_CIDMAPARAM_R_MODE_64X32 ; +else + cfg |=EXYNOS_CIDMAPARAM_R_MODE_LINEAR ; + +fimc_write (cfg,EXYNOS_CIDMAPARAM ); + +return fimc_src_set_fmt_order (ctx, fmt); +} + +static int fimc_src_set_transf (struct device *dev, +enum drm_exynos_degree degree, +enum drm_exynos_flip flip) +{ +struct fimc_context *ctx =get_fimc_context (dev); +struct exynos_drm_ippdrv *ippdrv = &ctx->ippdrv; +u32 cfg1, cfg2; + +DRM_DEBUG_KMS ("%s:degree[%d]flip[0x%x]\n" , __func__, + degree, flip); + + cfg1 =fimc_read (EXYNOS_MSCTRL ); + cfg1 &= ~(EXYNOS_MSCTRL_FLIP_X_MIRROR | +EXYNOS_MSCTRL_FLIP_Y_MIRROR ); + + cfg2 =fimc_read (EXYNOS_CITRGFMT ); + cfg2 &= ~EXYNOS_CITRGFMT_INROT90_CLOCKWISE ; + +switch (degree) { +case EXYNOS_DRM_DEGREE_0 : +if (flip &EXYNOS_DRM_FLIP_HORIZONTAL ) + cfg1 |=EXYNOS_MSCTRL_FLIP_X_MIRROR ; +if (flip &EXYNOS_DRM_FLIP_VERTICAL ) + cfg1 |=EXYNOS_MSCTRL_FLIP_Y_MIRROR ; +break ; +case EXYNOS_DRM_DEGREE_90 : + cfg2 |=EXYNOS_CITRGFMT_INROT90_CLOCKWISE ; +if (flip &EXYNOS_DRM_FLIP_HORIZONTAL ) + cfg1 |=EXYNOS_MSCTRL_FLIP_X_MIRROR ; +if (flip &EXYNOS_DRM_FLIP_VERTICAL ) + cfg1 |=EXYNOS_MSCTRL_FLIP_Y_MIRROR ; +break ; +case EXYNOS_DRM_DEGREE_180 : + cfg1 |= (EXYNOS_MSCTRL_FLIP_X_MIRROR | +EXYNOS_MSCTRL_FLIP_Y_MIRROR ); +if (flip &EXYNOS_DRM_FLIP_HORIZONTAL ) + cfg1 &= ~EXYNOS_MSCTRL_FLIP_X_MIRROR ; +if (flip &EXYNOS_DRM_FLIP_VERTICAL ) + cfg1 &= ~EXYNOS_MSCTRL_FLIP_Y_MIRROR ; +break ; +case EXYNOS_DRM_DEGREE_270 : + cfg1 |= (EXYNOS_MSCTRL_FLIP_X_MIRROR | +EXYNOS_MSCTRL_FLIP_Y_MIRROR ); + cfg2 |=EXYNOS_CITRGFMT_INROT90_CLOCKWISE ; +if (flip &EXYNOS_DRM_FLIP_HORIZONTAL ) + cfg1 &= ~EXYNOS_MSCTRL_FLIP_X_MIRROR ; +if (flip &EXYNOS_DRM_FLIP_VERTICAL ) + cfg1 &= ~EXYNOS_MSCTRL_FLIP_Y_MIRROR ; +break ; +default : +dev_err (ippdrv->dev,"inavlid degree value %d.\n" , degree); +return -EINVAL ; + } + +fimc_write (cfg1,EXYNOS_MSCTRL ); +fimc_write (cfg2,EXYNOS_CITRGFMT ); + +return (cfg2 &EXYNOS_CITRGFMT_INROT90_CLOCKWISE ) ?1 :0 ; +} + +static int fimc_set_window (struct fimc_context *ctx, +struct drm_exynos_pos *pos,struct drm_exynos_sz *sz) +{ +u32 cfg, h1, h2, v1, v2; + +/* cropped image */ + h1 = pos->x; + h2 = sz->hsize - pos->w - pos->x; + v1 = pos->y; + v2 = sz->vsize - pos->h - pos->y; + +DRM_DEBUG_KMS ("%s:x[%d]y[%d]w[%d]h[%d]hsize[%d]vsize[%d]\n" , + __func__, pos->x, pos->y, pos->w, pos->h, sz->hsize, sz->vsize); +DRM_DEBUG_KMS ("%s:h1[%d]h2[%d]v1[%d]v2[%d]\n" , __func__, + h1, h2, v1, v2); + +/* +* set window offset 1, 2 size +* check figure 43-21 in user manual +*/ + cfg =fimc_read (EXYNOS_CIWDOFST ); + cfg &= ~(EXYNOS_CIWDOFST_WINHOROFST_MASK | +EXYNOS_CIWDOFST_WINVEROFST_MASK ); + cfg |= (EXYNOS_CIWDOFST_WINHOROFST (h1) | +EXYNOS_CIWDOFST_WINVEROFST (v1)); + cfg |=EXYNOS_CIWDOFST_WINOFSEN ; +fimc_write (cfg,EXYNOS_CIWDOFST ); + + cfg = (EXYNOS_CIWDOFST2_WINHOROFST2 (h2) | +EXYNOS_CIWDOFST2_WINVEROFST2 (v2)); +fimc_write (cfg,EXYNOS_CIWDOFST2 ); + +return 0 ; +} + +static int fimc_src_set_size (struct device *dev,int swap, +struct drm_exynos_pos *pos,struct drm_exynos_sz *sz) +{ +struct fimc_context *ctx =get_fimc_context (dev); +struct drm_exynos_pos img_pos = *pos; +struct drm_exynos_sz img_sz = *sz; +u32 cfg; + +/* ToDo: check width and height */ + +DRM_DEBUG_KMS ("%s:swap[%d]hsize[%d]vsize[%d]\n" , + __func__, swap, sz->hsize, sz->vsize); + +/* original size */ + cfg = (EXYNOS_ORGISIZE_HORIZONTAL (img_sz.hsize) | +EXYNOS_ORGISIZE_VERTICAL (img_sz.vsize)); + +fimc_write (cfg,EXYNOS_ORGISIZE ); + +DRM_DEBUG_KMS ("%s:x[%d]y[%d]w[%d]h[%d]\n" , __func__, + pos->x, pos->y, pos->w, pos->h); + +if (swap) { + img_pos.w = pos->h; + img_pos.h = pos->w; + img_sz.hsize = sz->vsize; + img_sz.vsize = sz->hsize; + } + +/* set input DMA image size */ + cfg =fimc_read (EXYNOS_CIREAL_ISIZE ); + cfg &= ~(EXYNOS_CIREAL_ISIZE_HEIGHT_MASK | +EXYNOS_CIREAL_ISIZE_WIDTH_MASK ); + cfg |= (EXYNOS_CIREAL_ISIZE_WIDTH (img_pos.w) | +EXYNOS_CIREAL_ISIZE_HEIGHT (img_pos.h)); +fimc_write (cfg,EXYNOS_CIREAL_ISIZE ); + +/* +* set input FIFO image size +* for now, we support only ITU601 8 bit mode +*/ + cfg = (EXYNOS_CISRCFMT_ITU601_8BIT | +EXYNOS_CISRCFMT_SOURCEHSIZE (img_sz.hsize) | +EXYNOS_CISRCFMT_SOURCEVSIZE (img_sz.vsize)); +fimc_write (cfg,EXYNOS_CISRCFMT ); + +/* offset Y(RGB), Cb, Cr */ + cfg = (EXYNOS_CIIYOFF_HORIZONTAL (img_pos.x) | +EXYNOS_CIIYOFF_VERTICAL (img_pos.y)); +fimc_write (cfg,EXYNOS_CIIYOFF ); + cfg = (EXYNOS_CIICBOFF_HORIZONTAL (img_pos.x) | +EXYNOS_CIICBOFF_VERTICAL (img_pos.y)); +fimc_write (cfg,EXYNOS_CIICBOFF ); + cfg = (EXYNOS_CIICROFF_HORIZONTAL (img_pos.x) | +EXYNOS_CIICROFF_VERTICAL (img_pos.y)); +fimc_write (cfg,EXYNOS_CIICROFF ); + +return fimc_set_window (ctx, &img_pos, &img_sz); +} + +static int fimc_src_set_addr (struct device *dev, +struct drm_exynos_ipp_buf_info *buf_info,u32 buf_id, +enum drm_exynos_ipp_buf_type buf_type) +{ +struct fimc_context *ctx =get_fimc_context (dev); +struct exynos_drm_ippdrv *ippdrv = &ctx->ippdrv; +struct drm_exynos_ipp_cmd_node *c_node = ippdrv->cmd; +struct drm_exynos_ipp_property *property; +struct drm_exynos_ipp_config *config; + +if (!c_node) { +DRM_ERROR ("failed to get c_node.\n" ); +return -EINVAL ; + } + + property = &c_node->property; +if (!property) { +DRM_ERROR ("failed to get property.\n" ); +return -EINVAL ; + } + +DRM_DEBUG_KMS ("%s:prop_id[%d]buf_id[%d]buf_type[%d]\n" , __func__, + property->prop_id, buf_id, buf_type); + +if (buf_id >FIMC_MAX_SRC ) { +dev_info (ippdrv->dev,"inavlid buf_id %d.\n" , buf_id); +return -ENOMEM ; + } + +/* address register set */ +switch (buf_type) { +case IPP_BUF_ENQUEUE : + config = &property->config[EXYNOS_DRM_OPS_SRC ]; +fimc_write (buf_info->base[EXYNOS_DRM_PLANAR_Y ], +EXYNOS_CIIYSA (buf_id)); + +if (config->fmt ==DRM_FORMAT_YVU420 ) { +fimc_write (buf_info->base[EXYNOS_DRM_PLANAR_CR ], +EXYNOS_CIICBSA (buf_id)); +fimc_write (buf_info->base[EXYNOS_DRM_PLANAR_CB ], +EXYNOS_CIICRSA (buf_id)); + }else { +fimc_write (buf_info->base[EXYNOS_DRM_PLANAR_CB ], +EXYNOS_CIICBSA (buf_id)); +fimc_write (buf_info->base[EXYNOS_DRM_PLANAR_CR ], +EXYNOS_CIICRSA (buf_id)); + } +break ; +case IPP_BUF_DEQUEUE : +fimc_write (0x0 ,EXYNOS_CIIYSA (buf_id)); +fimc_write (0x0 ,EXYNOS_CIICBSA (buf_id)); +fimc_write (0x0 ,EXYNOS_CIICRSA (buf_id)); +break ; +default : +/* bypass */ +break ; + } + +return 0 ; +} + +static struct exynos_drm_ipp_ops fimc_src_ops = { + .set_fmt = fimc_src_set_fmt, + .set_transf = fimc_src_set_transf, + .set_size = fimc_src_set_size, + .set_addr = fimc_src_set_addr, +}; + +static int fimc_dst_set_fmt_order (struct fimc_context *ctx,u32 fmt) +{ +struct exynos_drm_ippdrv *ippdrv = &ctx->ippdrv; +u32 cfg; + +DRM_DEBUG_KMS ("%s:fmt[0x%x]\n" , __func__, fmt); + +/* RGB */ + cfg =fimc_read (EXYNOS_CISCCTRL ); + cfg &= ~EXYNOS_CISCCTRL_OUTRGB_FMT_RGB_MASK ; + +switch (fmt) { +case DRM_FORMAT_RGB565 : + cfg |=EXYNOS_CISCCTRL_OUTRGB_FMT_RGB565 ; +fimc_write (cfg,EXYNOS_CISCCTRL ); +return 0 ; +case DRM_FORMAT_RGB888 : + cfg |=EXYNOS_CISCCTRL_OUTRGB_FMT_RGB888 ; +fimc_write (cfg,EXYNOS_CISCCTRL ); +return 0 ; +case DRM_FORMAT_XRGB8888 : + cfg |= (EXYNOS_CISCCTRL_OUTRGB_FMT_RGB888 | +EXYNOS_CISCCTRL_EXTRGB_EXTENSION ); +fimc_write (cfg,EXYNOS_CISCCTRL ); +break ; +default : +/* bypass */ +break ; + } + +/* YUV */ + cfg =fimc_read (EXYNOS_CIOCTRL ); + cfg &= ~(EXYNOS_CIOCTRL_ORDER2P_MASK | +EXYNOS_CIOCTRL_ORDER422_MASK | +EXYNOS_CIOCTRL_YCBCR_PLANE_MASK ); + +switch (fmt) { +case DRM_FORMAT_XRGB8888 : + cfg |=EXYNOS_CIOCTRL_ALPHA_OUT ; +break ; +case DRM_FORMAT_YUYV : + cfg |=EXYNOS_CIOCTRL_ORDER422_YCBYCR ; +break ; +case DRM_FORMAT_YVYU : + cfg |=EXYNOS_CIOCTRL_ORDER422_YCRYCB ; +break ; +case DRM_FORMAT_UYVY : + cfg |=EXYNOS_CIOCTRL_ORDER422_CBYCRY ; +break ; +case DRM_FORMAT_VYUY : + cfg |=EXYNOS_CIOCTRL_ORDER422_CRYCBY ; +break ; +case DRM_FORMAT_NV21 : +case DRM_FORMAT_NV61 : + cfg |=EXYNOS_CIOCTRL_ORDER2P_LSB_CRCB ; + cfg |=EXYNOS_CIOCTRL_YCBCR_2PLANE ; +break ; +case DRM_FORMAT_YUV422 : +case DRM_FORMAT_YUV420 : +case DRM_FORMAT_YVU420 : + cfg |=EXYNOS_CIOCTRL_YCBCR_3PLANE ; +break ; +case DRM_FORMAT_NV12 : +case DRM_FORMAT_NV12MT : +case DRM_FORMAT_NV16 : + cfg |=EXYNOS_CIOCTRL_ORDER2P_LSB_CBCR ; + cfg |=EXYNOS_CIOCTRL_YCBCR_2PLANE ;
drivers/gpu/drm/exynos/exynos_drm_fimc.c line 842
Quoted 10 lines
drivers/gpu/drm/exynos/exynos_drm_fimc.c new file +10
-0+break ; +default : +dev_err (ippdrv->dev,"inavlid target yuv order 0x%x.\n" , fmt); +return -EINVAL ; + } + +fimc_write (cfg,EXYNOS_CIOCTRL ); + +return 0 ; +}
This function is also only called by fimc_dst_set_fmt and both functions have format check. So ther can be merged into one function.
Quoted 1,189 lines
drivers/gpu/drm/exynos/exynos_drm_fimc.c new file +1189
-0+ +static int fimc_dst_set_fmt (struct device *dev,u32 fmt) +{ +struct fimc_context *ctx =get_fimc_context (dev); +struct exynos_drm_ippdrv *ippdrv = &ctx->ippdrv; +u32 cfg; + +DRM_DEBUG_KMS ("%s:fmt[0x%x]\n" , __func__, fmt); + + cfg =fimc_read (EXYNOS_CIEXTEN ); + +if (fmt ==DRM_FORMAT_AYUV ) { + cfg |=EXYNOS_CIEXTEN_YUV444_OUT ; +fimc_write (cfg,EXYNOS_CIEXTEN ); + }else { + cfg &= ~EXYNOS_CIEXTEN_YUV444_OUT ; +fimc_write (cfg,EXYNOS_CIEXTEN ); + + cfg =fimc_read (EXYNOS_CITRGFMT ); + cfg &= ~EXYNOS_CITRGFMT_OUTFORMAT_MASK ; + +switch (fmt) { +case DRM_FORMAT_RGB565 : +case DRM_FORMAT_RGB888 : +case DRM_FORMAT_XRGB8888 : + cfg |=EXYNOS_CITRGFMT_OUTFORMAT_RGB ; +break ; +case DRM_FORMAT_YUYV : +case DRM_FORMAT_YVYU : +case DRM_FORMAT_UYVY : +case DRM_FORMAT_VYUY : + cfg |=EXYNOS_CITRGFMT_OUTFORMAT_YCBCR422_1PLANE ; +break ; +case DRM_FORMAT_NV16 : +case DRM_FORMAT_NV61 : +case DRM_FORMAT_YUV422 : + cfg |=EXYNOS_CITRGFMT_OUTFORMAT_YCBCR422 ; +break ; +case DRM_FORMAT_YUV420 : +case DRM_FORMAT_YVU420 : +case DRM_FORMAT_NV12 : +case DRM_FORMAT_NV12MT : +case DRM_FORMAT_NV21 : + cfg |=EXYNOS_CITRGFMT_OUTFORMAT_YCBCR420 ; +break ; +default : +dev_err (ippdrv->dev,"inavlid target format 0x%x.\n" , + fmt); +return -EINVAL ; + } + +fimc_write (cfg,EXYNOS_CITRGFMT ); + } + + cfg =fimc_read (EXYNOS_CIDMAPARAM ); + cfg &= ~EXYNOS_CIDMAPARAM_W_MODE_MASK ; + +if (fmt ==DRM_FORMAT_NV12MT ) + cfg |=EXYNOS_CIDMAPARAM_W_MODE_64X32 ; +else + cfg |=EXYNOS_CIDMAPARAM_W_MODE_LINEAR ; + +fimc_write (cfg,EXYNOS_CIDMAPARAM ); + +return fimc_dst_set_fmt_order (ctx, fmt); +} + +static int fimc_dst_set_transf (struct device *dev, +enum drm_exynos_degree degree, +enum drm_exynos_flip flip) +{ +struct fimc_context *ctx =get_fimc_context (dev); +struct exynos_drm_ippdrv *ippdrv = &ctx->ippdrv; +u32 cfg; + +DRM_DEBUG_KMS ("%s:degree[%d]flip[0x%x]\n" , __func__, + degree, flip); + + cfg =fimc_read (EXYNOS_CITRGFMT ); + cfg &= ~EXYNOS_CITRGFMT_FLIP_MASK ; + cfg &= ~EXYNOS_CITRGFMT_OUTROT90_CLOCKWISE ; + +switch (degree) { +case EXYNOS_DRM_DEGREE_0 : +if (flip &EXYNOS_DRM_FLIP_HORIZONTAL ) + cfg |=EXYNOS_CITRGFMT_FLIP_X_MIRROR ; +if (flip &EXYNOS_DRM_FLIP_VERTICAL ) + cfg |=EXYNOS_CITRGFMT_FLIP_Y_MIRROR ; +break ; +case EXYNOS_DRM_DEGREE_90 : + cfg |=EXYNOS_CITRGFMT_OUTROT90_CLOCKWISE ; +if (flip &EXYNOS_DRM_FLIP_HORIZONTAL ) + cfg |=EXYNOS_CITRGFMT_FLIP_X_MIRROR ; +if (flip &EXYNOS_DRM_FLIP_VERTICAL ) + cfg |=EXYNOS_CITRGFMT_FLIP_Y_MIRROR ; +break ; +case EXYNOS_DRM_DEGREE_180 : + cfg |= (EXYNOS_CITRGFMT_FLIP_X_MIRROR | +EXYNOS_CITRGFMT_FLIP_Y_MIRROR ); +if (flip &EXYNOS_DRM_FLIP_HORIZONTAL ) + cfg &= ~EXYNOS_CITRGFMT_FLIP_X_MIRROR ; +if (flip &EXYNOS_DRM_FLIP_VERTICAL ) + cfg &= ~EXYNOS_CITRGFMT_FLIP_Y_MIRROR ; +break ; +case EXYNOS_DRM_DEGREE_270 : + cfg |= (EXYNOS_CITRGFMT_OUTROT90_CLOCKWISE | +EXYNOS_CITRGFMT_FLIP_X_MIRROR | +EXYNOS_CITRGFMT_FLIP_Y_MIRROR ); +if (flip &EXYNOS_DRM_FLIP_HORIZONTAL ) + cfg &= ~EXYNOS_CITRGFMT_FLIP_X_MIRROR ; +if (flip &EXYNOS_DRM_FLIP_VERTICAL ) + cfg &= ~EXYNOS_CITRGFMT_FLIP_Y_MIRROR ; +break ; +default : +dev_err (ippdrv->dev,"inavlid degree value %d.\n" , degree); +return -EINVAL ; + } + +fimc_write (cfg,EXYNOS_CITRGFMT ); + +return (cfg &EXYNOS_CITRGFMT_OUTROT90_CLOCKWISE ) ?1 :0 ; +} + +static int fimc_get_ratio_shift (u32 src,u32 dst,u32 *ratio,u32 *shift) +{ +DRM_DEBUG_KMS ("%s:src[%d]dst[%d]\n" , __func__, src, dst); + +if (src >= dst *64 ) { +DRM_ERROR ("failed to make ratio and shift.\n" ); +return -EINVAL ; + }else if (src >= dst *32 ) { + *ratio =32 ; + *shift =5 ; + }else if (src >= dst *16 ) { + *ratio =16 ; + *shift =4 ; + }else if (src >= dst *8 ) { + *ratio =8 ; + *shift =3 ; + }else if (src >= dst *4 ) { + *ratio =4 ; + *shift =2 ; + }else if (src >= dst *2 ) { + *ratio =2 ; + *shift =1 ; + }else { + *ratio =1 ; + *shift =0 ; + } + +return 0 ; +} + +static int fimc_set_prescaler (struct fimc_context *ctx,struct fimc_scaler *sc, +struct drm_exynos_pos *src,struct drm_exynos_pos *dst) +{ +struct exynos_drm_ippdrv *ippdrv = &ctx->ippdrv; +u32 cfg, cfg_ext, shfactor; +u32 pre_dst_width, pre_dst_height; +u32 pre_hratio, hfactor, pre_vratio, vfactor; +int ret =0 ; +u32 src_w, src_h, dst_w, dst_h; + + cfg_ext =fimc_read (EXYNOS_CITRGFMT ); +if (cfg_ext &EXYNOS_CITRGFMT_INROT90_CLOCKWISE ) { + src_w = src->h; + src_h = src->w; + }else { + src_w = src->w; + src_h = src->h; + } + +if (cfg_ext &EXYNOS_CITRGFMT_OUTROT90_CLOCKWISE ) { + dst_w = dst->h; + dst_h = dst->w; + }else { + dst_w = dst->w; + dst_h = dst->h; + } + + ret =fimc_get_ratio_shift (src_w, dst_w, &pre_hratio, &hfactor); +if (ret) { +dev_err (ippdrv->dev,"failed to get ratio horizontal.\n" ); +return ret; + } + + ret =fimc_get_ratio_shift (src_h, dst_h, &pre_vratio, &vfactor); +if (ret) { +dev_err (ippdrv->dev,"failed to get ratio vertical.\n" ); +return ret; + } + + pre_dst_width = src_w / pre_hratio; + pre_dst_height = src_h / pre_vratio; +DRM_DEBUG_KMS ("%s:pre_dst_width[%d]pre_dst_height[%d]\n" , __func__, + pre_dst_width, pre_dst_height); +DRM_DEBUG_KMS ("%s:pre_hratio[%d]hfactor[%d]pre_vratio[%d]vfactor[%d]\n" , + __func__, pre_hratio, hfactor, pre_vratio, vfactor); + + sc->hratio = (src_w <<14 ) / (dst_w << hfactor); + sc->vratio = (src_h <<14 ) / (dst_h << vfactor); + sc->up_h = (dst_w >= src_w) ? true : false; + sc->up_v = (dst_h >= src_h) ? true : false; +DRM_DEBUG_KMS ("%s:hratio[%d]vratio[%d]up_h[%d]up_v[%d]\n" , + __func__, sc->hratio, sc->vratio, sc->up_h, sc->up_v); + + shfactor =10 - (hfactor + vfactor); +DRM_DEBUG_KMS ("%s:shfactor[%d]\n" , __func__, shfactor); + + cfg = (EXYNOS_CISCPRERATIO_SHFACTOR (shfactor) | +EXYNOS_CISCPRERATIO_PREHORRATIO (pre_hratio) | +EXYNOS_CISCPRERATIO_PREVERRATIO (pre_vratio)); +fimc_write (cfg,EXYNOS_CISCPRERATIO ); + + cfg = (EXYNOS_CISCPREDST_PREDSTWIDTH (pre_dst_width) | +EXYNOS_CISCPREDST_PREDSTHEIGHT (pre_dst_height)); +fimc_write (cfg,EXYNOS_CISCPREDST ); + +return ret; +} + +static void fimc_set_scaler (struct fimc_context *ctx,struct fimc_scaler *sc) +{ +u32 cfg, cfg_ext; + +DRM_DEBUG_KMS ("%s:range[%d]bypass[%d]up_h[%d]up_v[%d]\n" , + __func__, sc->range, sc->bypass, sc->up_h, sc->up_v); +DRM_DEBUG_KMS ("%s:hratio[%d]vratio[%d]\n" , + __func__, sc->hratio, sc->vratio); + + cfg =fimc_read (EXYNOS_CISCCTRL ); + cfg &= ~(EXYNOS_CISCCTRL_SCALERBYPASS | +EXYNOS_CISCCTRL_SCALEUP_H |EXYNOS_CISCCTRL_SCALEUP_V | +EXYNOS_CISCCTRL_MAIN_V_RATIO_MASK | +EXYNOS_CISCCTRL_MAIN_H_RATIO_MASK | +EXYNOS_CISCCTRL_CSCR2Y_WIDE | +EXYNOS_CISCCTRL_CSCY2R_WIDE ); + +if (sc->range) + cfg |= (EXYNOS_CISCCTRL_CSCR2Y_WIDE | +EXYNOS_CISCCTRL_CSCY2R_WIDE ); +if (sc->bypass) + cfg |=EXYNOS_CISCCTRL_SCALERBYPASS ; +if (sc->up_h) + cfg |=EXYNOS_CISCCTRL_SCALEUP_H ; +if (sc->up_v) + cfg |=EXYNOS_CISCCTRL_SCALEUP_V ; + + cfg |= (EXYNOS_CISCCTRL_MAINHORRATIO ((sc->hratio >>6 )) | +EXYNOS_CISCCTRL_MAINVERRATIO ((sc->vratio >>6 ))); +fimc_write (cfg,EXYNOS_CISCCTRL ); + + cfg_ext =fimc_read (EXYNOS_CIEXTEN ); + cfg_ext &= ~EXYNOS_CIEXTEN_MAINHORRATIO_EXT_MASK ; + cfg_ext &= ~EXYNOS_CIEXTEN_MAINVERRATIO_EXT_MASK ; + cfg_ext |= (EXYNOS_CIEXTEN_MAINHORRATIO_EXT (sc->hratio) | +EXYNOS_CIEXTEN_MAINVERRATIO_EXT (sc->vratio)); +fimc_write (cfg_ext,EXYNOS_CIEXTEN ); +} + +static int fimc_dst_set_size (struct device *dev,int swap, +struct drm_exynos_pos *pos,struct drm_exynos_sz *sz) +{ +struct fimc_context *ctx =get_fimc_context (dev); +struct drm_exynos_pos img_pos = *pos; +struct drm_exynos_sz img_sz = *sz; +u32 cfg; + +DRM_DEBUG_KMS ("%s:swap[%d]hsize[%d]vsize[%d]\n" , + __func__, swap, sz->hsize, sz->vsize); + +/* original size */ + cfg = (EXYNOS_ORGOSIZE_HORIZONTAL (img_sz.hsize) | +EXYNOS_ORGOSIZE_VERTICAL (img_sz.vsize)); + +fimc_write (cfg,EXYNOS_ORGOSIZE ); + +DRM_DEBUG_KMS ("%s:x[%d]y[%d]w[%d]h[%d]\n" , + __func__, pos->x, pos->y, pos->w, pos->h); + +/* CSC ITU */ + cfg =fimc_read (EXYNOS_CIGCTRL ); + cfg &= ~EXYNOS_CIGCTRL_CSC_MASK ; + +if (sz->hsize >=FIMC_WIDTH_ITU_709 ) + cfg |=EXYNOS_CIGCTRL_CSC_ITU709 ; +else + cfg |=EXYNOS_CIGCTRL_CSC_ITU601 ; + +fimc_write (cfg,EXYNOS_CIGCTRL ); + +if (swap) { + img_pos.w = pos->h; + img_pos.h = pos->w; + img_sz.hsize = sz->vsize; + img_sz.vsize = sz->hsize; + } + +/* target image size */ + cfg =fimc_read (EXYNOS_CITRGFMT ); + cfg &= ~(EXYNOS_CITRGFMT_TARGETH_MASK | +EXYNOS_CITRGFMT_TARGETV_MASK ); + cfg |= (EXYNOS_CITRGFMT_TARGETHSIZE (img_pos.w) | +EXYNOS_CITRGFMT_TARGETVSIZE (img_pos.h)); +fimc_write (cfg,EXYNOS_CITRGFMT ); + +/* target area */ + cfg =EXYNOS_CITAREA_TARGET_AREA (img_pos.w * img_pos.h); +fimc_write (cfg,EXYNOS_CITAREA ); + +/* ToDo: Move Scaler in this line and YUV */ + +/* offset Y(RGB), Cb, Cr */ + cfg = (EXYNOS_CIOYOFF_HORIZONTAL (img_pos.x) | +EXYNOS_CIOYOFF_VERTICAL (img_pos.y)); +fimc_write (cfg,EXYNOS_CIOYOFF ); + cfg = (EXYNOS_CIOCBOFF_HORIZONTAL (img_pos.x) | +EXYNOS_CIOCBOFF_VERTICAL (img_pos.y)); +fimc_write (cfg,EXYNOS_CIOCBOFF ); + cfg = (EXYNOS_CIOCROFF_HORIZONTAL (img_pos.x) | +EXYNOS_CIOCROFF_VERTICAL (img_pos.y)); +fimc_write (cfg,EXYNOS_CIOCROFF ); + +return 0 ; +} + +static int fimc_dst_get_buf_seq (struct fimc_context *ctx) +{ +u32 cfg, i, buf_num =0 ; +u32 mask =0x00000001 ; + + cfg =fimc_read (EXYNOS_CIFCNTSEQ ); + +for (i =0 ; i <FIMC_REG_SZ ; i++) +if (cfg & (mask << i)) + buf_num++; + +DRM_DEBUG_KMS ("%s:buf_num[%d]\n" , __func__, buf_num); + +return buf_num; +} + +static int fimc_dst_set_buf_seq (struct fimc_context *ctx,u32 buf_id, +enum drm_exynos_ipp_buf_type buf_type) +{ +struct exynos_drm_ippdrv *ippdrv = &ctx->ippdrv; +bool enable; +u32 cfg; +u32 mask =0x00000001 << buf_id; +unsigned long flags; +int ret =0 ; + +DRM_DEBUG_KMS ("%s:buf_id[%d]buf_type[%d]\n" , __func__, + buf_id, buf_type); + +spin_lock_irqsave (&ctx->lock, flags); + +/* mask register set */ + cfg =fimc_read (EXYNOS_CIFCNTSEQ ); + +switch (buf_type) { +case IPP_BUF_ENQUEUE : + enable = true; +break ; +case IPP_BUF_DEQUEUE : + enable = false; +break ; +default : +dev_err (ippdrv->dev,"invalid buf ctrl parameter.\n" ); + ret = -EINVAL ; + goto err_unlock; + } + +/* sequence id */ + cfg &= (~mask); + cfg |= (enable << buf_id); +fimc_write (cfg,EXYNOS_CIFCNTSEQ ); + +/* interrupt enable */ +if (buf_type ==IPP_BUF_ENQUEUE && +fimc_dst_get_buf_seq (ctx) >=FIMC_BUF_START ) +fimc_handle_irq (ctx, true, false, true); + +/* interrupt disable */ +if (buf_type ==IPP_BUF_DEQUEUE && +fimc_dst_get_buf_seq (ctx) <=FIMC_BUF_STOP ) +fimc_handle_irq (ctx, false, false, true); + +err_unlock: +spin_unlock_irqrestore (&ctx->lock, flags); +return ret; +} + +static int fimc_dst_set_addr (struct device *dev, +struct drm_exynos_ipp_buf_info *buf_info,u32 buf_id, +enum drm_exynos_ipp_buf_type buf_type) +{ +struct fimc_context *ctx =get_fimc_context (dev); +struct exynos_drm_ippdrv *ippdrv = &ctx->ippdrv; +struct drm_exynos_ipp_cmd_node *c_node = ippdrv->cmd; +struct drm_exynos_ipp_property *property; +struct drm_exynos_ipp_config *config; + +if (!c_node) { +DRM_ERROR ("failed to get c_node.\n" ); +return -EINVAL ; + } + + property = &c_node->property; +if (!property) { +DRM_ERROR ("failed to get property.\n" ); +return -EINVAL ; + } + +DRM_DEBUG_KMS ("%s:prop_id[%d]buf_id[%d]buf_type[%d]\n" , __func__, + property->prop_id, buf_id, buf_type); + +if (buf_id >FIMC_MAX_DST ) { +dev_info (ippdrv->dev,"inavlid buf_id %d.\n" , buf_id); +return -ENOMEM ; + } + +/* address register set */ +switch (buf_type) { +case IPP_BUF_ENQUEUE : + config = &property->config[EXYNOS_DRM_OPS_DST ]; + +fimc_write (buf_info->base[EXYNOS_DRM_PLANAR_Y ], +EXYNOS_CIOYSA (buf_id)); + +if (config->fmt ==DRM_FORMAT_YVU420 ) { +fimc_write (buf_info->base[EXYNOS_DRM_PLANAR_CR ], +EXYNOS_CIOCBSA (buf_id)); +fimc_write (buf_info->base[EXYNOS_DRM_PLANAR_CB ], +EXYNOS_CIOCRSA (buf_id)); + }else { +fimc_write (buf_info->base[EXYNOS_DRM_PLANAR_CB ], +EXYNOS_CIOCBSA (buf_id)); +fimc_write (buf_info->base[EXYNOS_DRM_PLANAR_CR ], +EXYNOS_CIOCRSA (buf_id)); + } +break ; +case IPP_BUF_DEQUEUE : +fimc_write (0x0 ,EXYNOS_CIOYSA (buf_id)); +fimc_write (0x0 ,EXYNOS_CIOCBSA (buf_id)); +fimc_write (0x0 ,EXYNOS_CIOCRSA (buf_id)); +break ; +default : +/* bypass */ +break ; + } + +return fimc_dst_set_buf_seq (ctx, buf_id, buf_type); +} + +static struct exynos_drm_ipp_ops fimc_dst_ops = { + .set_fmt = fimc_dst_set_fmt, + .set_transf = fimc_dst_set_transf, + .set_size = fimc_dst_set_size, + .set_addr = fimc_dst_set_addr, +}; + +static int fimc_power_on (struct fimc_context *ctx,bool enable) +{ +struct exynos_drm_ippdrv *ippdrv = &ctx->ippdrv; + +DRM_DEBUG_KMS ("%s:enable[%d]\n" , __func__, enable); + +if (enable) { +if (ctx->ver ==FIMC_EXYNOS_4210 ) { + ctx->sclk_fimc_clk =clk_get (ippdrv->dev,"sclk_fimc" ); +if (IS_ERR (ctx->sclk_fimc_clk)) { +dev_err (ippdrv->dev,"failed to get src fimc clock.\n" ); +return -EINVAL ; + } +clk_enable (ctx->sclk_fimc_clk); + }else +clk_enable (ctx->sclk_fimc_clk); + +clk_enable (ctx->fimc_clk); +clk_enable (ctx->wb_clk); +/* ToDo : wb_b_clk */ + ctx->suspended = false; + }else { +clk_disable (ctx->sclk_fimc_clk); +clk_disable (ctx->fimc_clk); +clk_disable (ctx->wb_clk); +/* ToDo : wb_b_clk */ + ctx->suspended = true; + } + +return 0 ; +} + +static irqreturn_t fimc_irq_handler (int irq,void *dev_id) +{ +struct fimc_context *ctx = dev_id; +struct exynos_drm_ippdrv *ippdrv = &ctx->ippdrv; +struct drm_exynos_ipp_cmd_node *c_node = ippdrv->cmd; +struct drm_exynos_ipp_event_work *event_work = + c_node->event_work; +int buf_id; + +DRM_DEBUG_KMS ("%s:fimc id[%d]\n" , __func__, ctx->id); + +fimc_clear_irq (ctx); +if (fimc_check_ovf (ctx)) +return IRQ_NONE ; + +if (!fimc_check_frame_end (ctx)) +return IRQ_NONE ; + + buf_id =fimc_get_buf_id (ctx); +if (buf_id <0 ) +return IRQ_HANDLED ; + +DRM_DEBUG_KMS ("%s:buf_id[%d]\n" , __func__, buf_id); + +if (fimc_dst_set_buf_seq (ctx, buf_id,IPP_BUF_DEQUEUE ) <0 ) { +DRM_ERROR ("failed to dequeue.\n" ); +return IRQ_HANDLED ; + } + + event_work->ippdrv = ippdrv; + event_work->buf_id[EXYNOS_DRM_OPS_DST ] = buf_id; +queue_work (ippdrv->event_workq, (struct work_struct *)event_work); + +return IRQ_HANDLED ; +} + +static int fimc_init_prop_list (struct drm_exynos_ipp_prop_list **prop_list) +{ +DRM_DEBUG_KMS ("%s\n" , __func__); + +if (!prop_list) { +DRM_ERROR ("empty prop_list\n" ); +return -EINVAL ; + } + + *prop_list =kzalloc (sizeof (**prop_list),GFP_KERNEL ); +if (!*prop_list) { +DRM_ERROR ("failed to alloc property list.\n" ); +return -ENOMEM ; + } +/*ToDo : fix supported function list*/ + (*prop_list)->version =1 ; + (*prop_list)->writeback =1 ; + (*prop_list)->refresh_min =12 ; + (*prop_list)->refresh_max =60 ; + (*prop_list)->flip = (1 <<EXYNOS_DRM_FLIP_NONE ) | + (1 <<EXYNOS_DRM_FLIP_VERTICAL ) | + (1 <<EXYNOS_DRM_FLIP_HORIZONTAL ); + (*prop_list)->degree = (1 <<EXYNOS_DRM_DEGREE_0 ) | + (1 <<EXYNOS_DRM_DEGREE_90 ) | + (1 <<EXYNOS_DRM_DEGREE_180 ) | + (1 <<EXYNOS_DRM_DEGREE_270 ); + (*prop_list)->csc =1 ; + (*prop_list)->crop =1 ; + (*prop_list)->crop_max.hsize =8192 ; + (*prop_list)->crop_max.vsize =8192 ; + (*prop_list)->crop_min.hsize =32 ; + (*prop_list)->crop_min.vsize =32 ; + (*prop_list)->scale =1 ; + (*prop_list)->scale_max.hsize =4224 ; + (*prop_list)->scale_max.vsize =4224 ; + (*prop_list)->scale_min.hsize =32 ; + (*prop_list)->scale_min.vsize =32 ; + +return 0 ; +} + +static int fimc_ippdrv_check_property (struct device *dev, +struct drm_exynos_ipp_property *property) +{ +struct fimc_context *ctx =get_fimc_context (dev); +struct exynos_drm_ippdrv *ippdrv = &ctx->ippdrv; +struct drm_exynos_ipp_prop_list *pp = ippdrv->prop_list; +struct drm_exynos_ipp_config *config; +struct drm_exynos_pos *pos; +struct drm_exynos_sz *sz; +bool swap; +int i; + +DRM_DEBUG_KMS ("%s\n" , __func__); + +for_each_ipp_ops (i) { +if ((i ==EXYNOS_DRM_OPS_SRC ) && + (property->cmd ==IPP_CMD_WB )) +continue ; + + config = &property->config[i]; + pos = &config->pos; + sz = &config->sz; + +/* check for flip */ +switch (config->flip) { +case EXYNOS_DRM_FLIP_NONE : +case EXYNOS_DRM_FLIP_VERTICAL : +case EXYNOS_DRM_FLIP_HORIZONTAL : +/* No problem */ +break ; +default : +DRM_ERROR ("invalid flip.\n" ); + goto err_property; + } + +/* check for degree */ +switch (config->degree) { +case EXYNOS_DRM_DEGREE_90 : +case EXYNOS_DRM_DEGREE_270 : + swap = true; +break ; +case EXYNOS_DRM_DEGREE_0 : +case EXYNOS_DRM_DEGREE_180 : + swap = false; +break ; +default : +DRM_ERROR ("invalid degree.\n" ); + goto err_property; + } + +/* check for buffer bound */ +if ((pos->x + pos->w > sz->hsize) || + (pos->y + pos->h > sz->vsize)) { +DRM_ERROR ("out of buf bound.\n" ); + goto err_property; + } + +/* check for crop */ +if ((i ==EXYNOS_DRM_OPS_SRC ) && (pp->crop)) { +if (swap) { +if ((pos->h < pp->crop_min.hsize) || + (sz->vsize > pp->crop_max.hsize) || + (pos->w < pp->crop_min.vsize) || + (sz->hsize > pp->crop_max.vsize)) { +DRM_ERROR ("out of crop size.\n" ); + goto err_property; + } + }else { +if ((pos->w < pp->crop_min.hsize) || + (sz->hsize > pp->crop_max.hsize) || + (pos->h < pp->crop_min.vsize) || + (sz->vsize > pp->crop_max.vsize)) { +DRM_ERROR ("out of crop size.\n" ); + goto err_property; + } + } + } + +/* check for scale */ +if ((i ==EXYNOS_DRM_OPS_DST ) && (pp->scale)) { +if (swap) { +if ((pos->h < pp->scale_min.hsize) || + (sz->vsize > pp->scale_max.hsize) || + (pos->w < pp->scale_min.vsize) || + (sz->hsize > pp->scale_max.vsize)) { +DRM_ERROR ("out of scale size.\n" ); + goto err_property; + } + }else { +if ((pos->w < pp->scale_min.hsize) || + (sz->hsize > pp->scale_max.hsize) || + (pos->h < pp->scale_min.vsize) || + (sz->vsize > pp->scale_max.vsize)) { +DRM_ERROR ("out of scale size.\n" ); + goto err_property; + } + } + } + } + +return 0 ; + +err_property: +for_each_ipp_ops (i) { +if ((i ==EXYNOS_DRM_OPS_SRC ) && + (property->cmd ==IPP_CMD_WB )) +continue ; + + config = &property->config[i]; + pos = &config->pos; + sz = &config->sz; + +DRM_ERROR ("[%s]f[%d]r[%d]pos[%d %d %d %d]sz[%d %d]\n" , + i ?"dst" :"src" , config->flip, config->degree, + pos->x, pos->y, pos->w, pos->h, + sz->hsize, sz->vsize); + } + +return -EINVAL ; +} + +static int fimc_ippdrv_reset (struct device *dev) +{ +struct fimc_context *ctx =get_fimc_context (dev); + +DRM_DEBUG_KMS ("%s\n" , __func__); + +/* reset h/w block */ +fimc_sw_reset (ctx, false); + +/* reset scaler capability */ +memset (&ctx->sc,0x0 ,sizeof (ctx->sc)); + +return 0 ; +} + +static int fimc_check_prepare (struct fimc_context *ctx) +{ +/* ToDo: check prepare using read register */ +DRM_DEBUG_KMS ("%s\n" , __func__); + +return 0 ; +} + +static int fimc_ippdrv_start (struct device *dev,enum drm_exynos_ipp_cmd cmd) +{ +struct fimc_context *ctx =get_fimc_context (dev); +struct exynos_drm_ippdrv *ippdrv = &ctx->ippdrv; +struct drm_exynos_ipp_cmd_node *c_node = ippdrv->cmd; +struct drm_exynos_ipp_property *property; +struct drm_exynos_ipp_config *config; +struct drm_exynos_pos img_pos[EXYNOS_DRM_OPS_MAX ]; +struct drm_exynos_ipp_set_wb set_wb; +int ret, i; +u32 cfg0, cfg1; + +DRM_DEBUG_KMS ("%s:cmd[%d]\n" , __func__, cmd); + +if (!c_node) { +DRM_ERROR ("failed to get c_node.\n" ); +return -EINVAL ; + } + + property = &c_node->property; +if (!property) { +DRM_ERROR ("failed to get property.\n" ); +return -EINVAL ; + } + + ret =fimc_check_prepare (ctx); +if (ret) { +dev_err (dev,"failed to check prepare.\n" ); +return ret; + } + +fimc_handle_irq (ctx, true, false, true); + +/* ToDo: window size, prescaler config */ +for_each_ipp_ops (i) { + config = &property->config[i]; + img_pos[i] = config->pos; + } + + ret =fimc_set_prescaler (ctx, &ctx->sc, + &img_pos[EXYNOS_DRM_OPS_SRC ], + &img_pos[EXYNOS_DRM_OPS_DST ]); +if (ret) { +dev_err (dev,"failed to set precalser.\n" ); +return ret; + } + +/* If set ture, we can save jpeg about screen */ +fimc_handle_jpeg (ctx, false); +fimc_set_scaler (ctx, &ctx->sc); +fimc_set_polarity (ctx, &ctx->pol); + +switch (cmd) { +case IPP_CMD_M2M : +fimc_set_type_ctrl (ctx,FIMC_WB_NONE ); +fimc_handle_lastend (ctx, false); + +/* setup dma */ + cfg0 =fimc_read (EXYNOS_MSCTRL ); + cfg0 &= ~EXYNOS_MSCTRL_INPUT_MASK ; + cfg0 |=EXYNOS_MSCTRL_INPUT_MEMORY ; +fimc_write (cfg0,EXYNOS_MSCTRL ); +break ; +case IPP_CMD_WB : +fimc_set_type_ctrl (ctx,FIMC_WB_A ); +fimc_handle_lastend (ctx, true); + +/* setup FIMD */ +fimc_set_camblk_fimd0_wb (ctx); + +/* ToDo: need to replace the property structure. */ + set_wb.enable =1 ; + set_wb.refresh = property->reserved; +exynos_drm_ippnb_send_event (IPP_SET_WRITEBACK , (void *)&set_wb); +break ; +case IPP_CMD_OUTPUT : +default : + ret = -EINVAL ; +dev_err (dev,"invalid operations.\n" ); +return ret; + } + +/* Reset status */ +fimc_write (0x0 ,EXYNOS_CISTATUS ); + + cfg0 =fimc_read (EXYNOS_CIIMGCPT ); + cfg0 &= ~EXYNOS_CIIMGCPT_IMGCPTEN_SC ; + cfg0 |=EXYNOS_CIIMGCPT_IMGCPTEN_SC ; + +/* Scaler */ + cfg1 =fimc_read (EXYNOS_CISCCTRL ); + cfg1 &= ~EXYNOS_CISCCTRL_SCAN_MASK ; + cfg1 |= (EXYNOS_CISCCTRL_PROGRESSIVE | +EXYNOS_CISCCTRL_SCALERSTART ); + +fimc_write (cfg1,EXYNOS_CISCCTRL ); + +/* Enable image capture*/ + cfg0 |=EXYNOS_CIIMGCPT_IMGCPTEN ; +fimc_write (cfg0,EXYNOS_CIIMGCPT ); + +/* Disable frame end irq */ + cfg0 =fimc_read (EXYNOS_CIGCTRL ); + cfg0 &= ~EXYNOS_CIGCTRL_IRQ_END_DISABLE ; +fimc_write (cfg0,EXYNOS_CIGCTRL ); + + cfg0 =fimc_read (EXYNOS_CIOCTRL ); + cfg0 &= ~EXYNOS_CIOCTRL_WEAVE_MASK ; +fimc_write (cfg0,EXYNOS_CIOCTRL ); + +/* ToDo: m2m start errata - refer fimd */ +if (cmd ==IPP_CMD_M2M ) { + cfg0 =fimc_read (EXYNOS_MSCTRL ); + cfg0 |=EXYNOS_MSCTRL_ENVID ; +fimc_write (cfg0,EXYNOS_MSCTRL ); + + cfg0 =fimc_read (EXYNOS_MSCTRL ); + cfg0 |=EXYNOS_MSCTRL_ENVID ; +fimc_write (cfg0,EXYNOS_MSCTRL ); + } + +return 0 ; +} + +static void fimc_ippdrv_stop (struct device *dev,enum drm_exynos_ipp_cmd cmd) +{ +struct fimc_context *ctx =get_fimc_context (dev); +struct drm_exynos_ipp_set_wb set_wb = {0 ,0 }; +u32 cfg; + +DRM_DEBUG_KMS ("%s:cmd[%d]\n" , __func__, cmd); + +switch (cmd) { +case IPP_CMD_M2M : +/* Source clear */ + cfg =fimc_read (EXYNOS_MSCTRL ); + cfg &= ~EXYNOS_MSCTRL_INPUT_MASK ; + cfg &= ~EXYNOS_MSCTRL_ENVID ; +fimc_write (cfg,EXYNOS_MSCTRL ); +break ; +case IPP_CMD_WB : +exynos_drm_ippnb_send_event (IPP_SET_WRITEBACK , (void *)&set_wb); +break ; +case IPP_CMD_OUTPUT : +default : +dev_err (dev,"invalid operations.\n" ); +break ; + } + +fimc_handle_irq (ctx, false, false, true); + +/* reset sequence */ +fimc_write (0x0 ,EXYNOS_CIFCNTSEQ ); + +/* Scaler disable */ + cfg =fimc_read (EXYNOS_CISCCTRL ); + cfg &= ~EXYNOS_CISCCTRL_SCALERSTART ; +fimc_write (cfg,EXYNOS_CISCCTRL ); + +/* Disable image capture */ + cfg =fimc_read (EXYNOS_CIIMGCPT ); + cfg &= ~(EXYNOS_CIIMGCPT_IMGCPTEN_SC |EXYNOS_CIIMGCPT_IMGCPTEN ); +fimc_write (cfg,EXYNOS_CIIMGCPT ); + +/* Enable frame end irq */ + cfg =fimc_read (EXYNOS_CIGCTRL ); + cfg |=EXYNOS_CIGCTRL_IRQ_END_DISABLE ; +fimc_write (cfg,EXYNOS_CIGCTRL ); +} + +static struct fimc_capability *fimc_get_capability ( +enum exynos_drm_fimc_ver ver) +{ +struct fimc_capability *capa; + +DRM_DEBUG_KMS ("%s:ver[0x%x]\n" , __func__, ver); + +/* ToDo: version check */ +switch (ver) { +case FIMC_EXYNOS_4412 : +case FIMC_EXYNOS_4412_R2 : +default : + capa = fimc51_capa; +break ; + } + +return capa; +} + +static int fimc_get_clk_rate (enum exynos_drm_fimc_ver ver) +{ +int clk_rate; + +DRM_DEBUG_KMS ("%s:ver[0x%x]\n" , __func__, ver); + +switch (ver) { +case FIMC_EXYNOS_4412_R2 : + clk_rate =FIMC_CLK_RATE_R2 ; +break ; +case FIMC_EXYNOS_4412 : +default : + clk_rate =FIMC_CLK_RATE ; +break ; + } + +return clk_rate; +} + +static int __devinit fimc_probe (struct platform_device *pdev) +{ +struct device *dev = &pdev->dev; +struct fimc_context *ctx; +struct clk *parent_clk; +struct resource *res; +struct exynos_drm_ippdrv *ippdrv; +struct exynos_drm_fimc_pdata *pdata; +int ret = -EINVAL ; + + pdata = pdev->dev.platform_data; +if (!pdata) { +dev_err (dev,"no platform data specified.\n" ); +return -EINVAL ; + } + + ctx =kzalloc (sizeof (*ctx),GFP_KERNEL ); +if (!ctx) +return -ENOMEM ; + +/* clock control */ + ctx->sclk_fimc_clk =clk_get (dev,"sclk_fimc" ); +if (IS_ERR (ctx->sclk_fimc_clk)) { +dev_err (dev,"failed to get src fimc clock.\n" ); + ret =PTR_ERR (ctx->sclk_fimc_clk); + goto err_ctx; + } +clk_enable (ctx->sclk_fimc_clk); + + ctx->fimc_clk =clk_get (dev,"fimc" ); +if (IS_ERR (ctx->fimc_clk)) { +dev_err (dev,"failed to get fimc clock.\n" ); + ret =PTR_ERR (ctx->fimc_clk); +clk_put (ctx->sclk_fimc_clk); + goto err_ctx; + } + + ctx->wb_clk =clk_get (dev,"pxl_async0" ); +if (IS_ERR (ctx->wb_clk)) { +dev_err (dev,"failed to get writeback a clock.\n" ); + ret =PTR_ERR (ctx->wb_clk); +clk_put (ctx->sclk_fimc_clk); +clk_put (ctx->fimc_clk); + goto err_ctx; + } + + ctx->wb_b_clk =clk_get (dev,"pxl_async1" ); +if (IS_ERR (ctx->wb_b_clk)) { +dev_err (dev,"failed to get writeback b clock.\n" ); + ret =PTR_ERR (ctx->wb_b_clk); +clk_put (ctx->sclk_fimc_clk); +clk_put (ctx->fimc_clk); +clk_put (ctx->wb_clk); + goto err_ctx; + } + +if (pdata->ver ==FIMC_EXYNOS_4210 ) + parent_clk =clk_get (dev,"mout_mpll" ); +else + parent_clk =clk_get (dev,"mout_mpll_user" ); + +if (IS_ERR (parent_clk)) { +dev_err (dev,"failed to get parent clock.\n" ); + ret =PTR_ERR (parent_clk); +clk_put (ctx->sclk_fimc_clk); +clk_put (ctx->fimc_clk); +clk_put (ctx->wb_clk); +clk_put (ctx->wb_b_clk); + goto err_ctx; + } + +if (clk_set_parent (ctx->sclk_fimc_clk, parent_clk)) { +dev_err (dev,"failed to set parent.\n" ); +clk_put (parent_clk); +clk_put (ctx->sclk_fimc_clk); +clk_put (ctx->fimc_clk); +clk_put (ctx->wb_clk); +clk_put (ctx->wb_b_clk); + goto err_ctx; + } +clk_put (parent_clk); +clk_set_rate (ctx->sclk_fimc_clk,fimc_get_clk_rate (pdata->ver)); +if (pdata->ver ==FIMC_EXYNOS_4210 ) +clk_put (ctx->sclk_fimc_clk); +else +clk_disable (ctx->sclk_fimc_clk); + +/* resource memory */ + res =platform_get_resource (pdev,IORESOURCE_MEM ,0 ); +if (!res) { +dev_err (dev,"failed to find registers.\n" ); + ret = -ENOENT ; + goto err_clk; + } + + ctx->regs_res =request_mem_region (res->start,resource_size (res), +dev_name (dev)); +if (!ctx->regs_res) { +dev_err (dev,"failed to claim register region.\n" ); + ret = -ENOENT ; + goto err_clk; + } + + ctx->regs =ioremap (res->start,resource_size (res)); +if (!ctx->regs) { +dev_err (dev,"failed to map registers.\n" ); + ret = -ENXIO ; + goto err_req_region; + } + +/* resource irq */ + res =platform_get_resource (pdev,IORESOURCE_IRQ ,0 ); +if (!res) { +dev_err (dev,"failed to request irq resource.\n" ); + goto err_get_regs; + } + + ctx->irq = res->start; + ret =request_threaded_irq (ctx->irq,NULL , fimc_irq_handler, +IRQF_ONESHOT ,"drm_fimc" , ctx); +if (ret <0 ) { +dev_err (dev,"failed to request irq.\n" ); + goto err_get_regs; + } + +/* context initailization */ + ctx->ver = pdata->ver; + ctx->id = pdev->id; + ctx->capa =fimc_get_capability (ctx->ver); +if (!ctx->capa) { +dev_err (dev,"failed to get capability.\n" ); + goto err_get_irq; + } + ctx->pol = pdata->pol; + + ippdrv = &ctx->ippdrv; + ippdrv->dev = dev; + ippdrv->ops[EXYNOS_DRM_OPS_SRC ] = &fimc_src_ops; + ippdrv->ops[EXYNOS_DRM_OPS_DST ] = &fimc_dst_ops; + ippdrv->check_property = fimc_ippdrv_check_property; + ippdrv->reset = fimc_ippdrv_reset; + ippdrv->start = fimc_ippdrv_start; + ippdrv->stop = fimc_ippdrv_stop; + ret =fimc_init_prop_list (&ippdrv->prop_list); +if (ret <0 ) { +dev_err (dev,"failed to init property list.\n" ); + goto err_get_irq; + } + +DRM_DEBUG_KMS ("%s:id[%d]ippdrv[0x%x]\n" , __func__, ctx->id, + (int )ippdrv); + +spin_lock_init (&ctx->lock); +platform_set_drvdata (pdev, ctx); + +pm_runtime_set_active (dev); +pm_runtime_enable (dev); + + ret =exynos_drm_ippdrv_register (ippdrv); +if (ret <0 ) { +dev_err (dev,"failed to register drm fimc device.\n" ); + goto err_ippdrv_register; + } + +dev_info (&pdev->dev,"drm fimc registered successfully.\n" ); + +return 0 ; + +err_ippdrv_register: +kfree (ippdrv->prop_list); +pm_runtime_disable (dev); +free_irq (ctx->irq, ctx); +err_get_irq: +free_irq (ctx->irq, ctx); +err_get_regs: +iounmap (ctx->regs); +err_req_region: +release_resource (ctx->regs_res); +kfree (ctx->regs_res); +err_clk: +clk_put (ctx->sclk_fimc_clk); +clk_put (ctx->fimc_clk); +clk_put (ctx->wb_clk); +clk_put (ctx->wb_b_clk); +err_ctx: +kfree (ctx); +return ret; +} + +static int __devexit fimc_remove(struct platform_device *pdev) +{ +struct device *dev = &pdev->dev; +struct fimc_context *ctx =get_fimc_context (dev); +struct exynos_drm_ippdrv *ippdrv = &ctx->ippdrv; + +kfree (ippdrv->prop_list); +exynos_drm_ippdrv_unregister (ippdrv); + +pm_runtime_set_suspended (dev); +pm_runtime_disable (dev); + +free_irq (ctx->irq, ctx); +iounmap (ctx->regs); +release_resource (ctx->regs_res); +kfree (ctx->regs_res); + +clk_put (ctx->sclk_fimc_clk); +clk_put (ctx->fimc_clk); +clk_put (ctx->wb_clk); +clk_put (ctx->wb_b_clk); + +kfree (ctx); + +return 0 ; +} + +#ifdef CONFIG_PM_SLEEP +static int fimc_suspend (struct device *dev) +{ +struct fimc_context *ctx =get_fimc_context (dev); + +DRM_DEBUG_KMS ("%s:id[%d]\n" , __func__, ctx->id); +if (pm_runtime_suspended (dev)) +return 0 ; +/* ToDo */ +return fimc_power_on (ctx, false); +} + +static int fimc_resume (struct device *dev) +{ +struct fimc_context *ctx =get_fimc_context (dev); + +DRM_DEBUG_KMS ("%s:id[%d]\n" , __func__, ctx->id); +if (!pm_runtime_suspended (dev)) +return fimc_power_on (ctx, true); +/* ToDo */ +return 0 ; +} +#endif + +#ifdef CONFIG_PM_RUNTIME +static int fimc_runtime_suspend (struct device *dev) +{ +struct fimc_context *ctx =get_fimc_context (dev); + +DRM_DEBUG_KMS ("%s:id[%d]\n" , __func__, ctx->id); +/* ToDo */ +return fimc_power_on (ctx, false); +} + +static int fimc_runtime_resume (struct device *dev) +{ +struct fimc_context *ctx =get_fimc_context (dev); + +DRM_DEBUG_KMS ("%s:id[%d]\n" , __func__, ctx->id); +/* ToDo */ +return fimc_power_on (ctx, true); +} +#endif + +static const struct dev_pm_ops fimc_pm_ops = { + SET_SYSTEM_SLEEP_PM_OPS(fimc_suspend, fimc_resume) +SET_RUNTIME_PM_OPS (fimc_runtime_suspend, fimc_runtime_resume,NULL ) +}; + +/* ToDo: need to check use case platform_device_id */
drivers/gpu/drm/exynos/exynos_drm_fimc.c line 2041
Quoted 10 lines
drivers/gpu/drm/exynos/exynos_drm_fimc.c new file +10
-0+struct platform_driver fimc_driver = { + .probe = fimc_probe, + .remove =__devexit_p (fimc_remove), + .driver = { + .name ="exynos-drm-fimc" , + .owner =THIS_MODULE , + .pm = &fimc_pm_ops, + }, +}; +
<snip>
Best Regards,
- Seung-Woo Kim
Signature · 8 lines
Seung-Woo Kim Samsung Software R&D Center -- _______________________________________________ dri-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [RFC 2/4] drm/exynos: add fimc ipp driver
Dear Seung-Woo Kim
Thank's for your comment. and you gave the first comment. :)
I also considered about mergeing set_fmt, set_fmt_order.
but If we merge this function, we need to seperate all "switch case" routine. so, complexity has increased after mergeing.
and I designed this set_fmt function with two path. first)
- set up the format information using relative register second)
- set up the format ordering using relative register.
one more think about this design concept.
and If you need to merge this function, please give one more comments. I will change and resent it.
and I commented about your comment.
Thank's
Quoted 519 lines · 김승우
Hi Eunchul,
IMHO, each function for source and destination has quite similar routine and it seems that there are some redundant code. I'm not sure these duplicated code can be removed with mergeing similar part.
Some comments are below.
Quoted 22 lines · Eunchul Kim
FIMC is stand for Fully Interfactive Mobile Camera and
supports image scaler/rotator/crop/flip/csc and input/output DMA operations. input DMA reads image data from the memory.
output DMA writes image data to memory.
FIMC supports image rotation and image effect functions.
also supports writeback and display output operations.Signed-off-by Eunchul Kim <[email protected]>Signed-off-by Jinyoung Jeon <[email protected]>--- drivers/gpu/drm/exynos/Kconfig | 6 + drivers/gpu/drm/exynos/Makefile | 1 + drivers/gpu/drm/exynos/exynos_drm_drv.c | 15 + drivers/gpu/drm/exynos/exynos_drm_drv.h | 1 + drivers/gpu/drm/exynos/exynos_drm_fimc.c | 2041 ++++++++++++++++++++++++++++++ drivers/gpu/drm/exynos/exynos_drm_fimc.h | 35 + drivers/gpu/drm/exynos/regs-fimc.h | 669 ++++++++++ include/drm/exynos_drm.h | 33 + 8 files changed, 2801 insertions(+), 0 deletions(-)create mode 100644
drivers/gpu/drm/exynos/exynos_drm_fimc.ccreate mode 100644drivers/gpu/drm/exynos/exynos_drm_fimc.hcreate mode 100644drivers/gpu/drm/exynos/regs-fimc.h<snip>
Quoted 485 lines
drivers/gpu/drm/exynos/exynos_drm_fimc.c new file +479
-0@@ -0,0 +1,2041 @@ +/* +* Copyright (C) 2012 Samsung Electronics Co.Ltd +* Authors: +* Eunchul Kim <[email protected]> +* Jinyoung Jeon <[email protected]> +* Sangmin Lee <[email protected]> +* +* This program is free software; you can redistribute it and/or modify it +* under the terms of the GNU General Public License as published by the +* Free Software Foundation; either version 2 of the License, or (at your +* option) any later version. +* +*/ +#include <linux/kernel.h> +#include <linux/module.h> +#include <linux/platform_device.h> +#include <linux/clk.h> +#include <linux/pm_runtime.h> +#include <plat/map-base.h> + +#include <drm/drmP.h> +#include <drm/exynos_drm.h> +#include "regs-fimc.h" +#include "exynos_drm_drv.h" +#include "exynos_drm_gem.h" +#include "exynos_drm_ipp.h" +#include "exynos_drm_fimc.h" + +/* +* FIMC is stand for Fully Interactive Mobile Camera and +* supports image scaler/rotator and input/output DMA operations. +* input DMA reads image data from the memory. +* output DMA writes image data to memory. +* FIMC supports image rotation and image effect functions. +*/ + +#define FIMC_MAX_DEVS 4 +#define FIMC_MAX_SRC 2 +#define FIMC_MAX_DST 32 +#define FIMC_CLK_RATE 166750000 +#define FIMC_CLK_RATE_R2 180000000 +#define FIMC_BUF_STOP 1 +#define FIMC_BUF_START 2 +#define FIMC_REG_SZ 32 +#define FIMC_WIDTH_ITU_709 1280 + +#define get_fimc_context (dev) platform_get_drvdata(to_platform_device(dev)) +#define get_ctx_from_ippdrv (ippdrv) container_of(ippdrv,\ + struct fimc_context, ippdrv); +#define fimc_read (offset) readl(ctx->regs + (offset)); +#define fimc_write (cfg, offset) writel(cfg, ctx->regs + (offset)); + +enum fimc_wb { +FIMC_WB_NONE , +FIMC_WB_A , +FIMC_WB_B , +}; + +/* +* A structure of scaler. +* +* @range: narrow, wide. +* @bypass: unused scaler path. +* @up_h: horizontal scale up. +* @up_v: vertical scale up. +* @hratio: horizontal ratio. +* @vratio: vertical ratio. +*/ +struct fimc_scaler { +bool range; +bool bypass; +bool up_h; +bool up_v; +u32 hratio; +u32 vratio; +}; + +/* +* A structure of scaler capability. +* +* find user manual table 43-1. +* @in_hori: scaler input horizontal size. +* @bypass: scaler bypass mode. +* @dst_h_wo_rot: target horizontal size without output rotation. +* @dst_h_rot: target horizontal size with output rotation. +* @rl_w_wo_rot: real width without input rotation. +* @rl_h_rot: real height without output rotation. +*/ +struct fimc_capability { +/* scaler */ +u32 in_hori; +u32 bypass; +/* output rotator */ +u32 dst_h_wo_rot; +u32 dst_h_rot; +/* input rotator */ +u32 rl_w_wo_rot; +u32 rl_h_rot; +}; + +/* +* A structure of fimc context. +* +* @ippdrv: prepare initialization using ippdrv. +* @regs_res: register resources. +* @regs: memory mapped io registers. +* @lock: locking of operations. +* @sclk_fimc_clk: fimc source clock. +* @fimc_clk: fimc clock. +* @wb_clk: writeback a clock. +* @wb_b_clk: writeback b clock. +* @sc: scaler infomations. +* @capa: scaler capability. +* @odr: ordering of YUV. +* @ver: fimc version. +* @pol: porarity of writeback. +* @id: fimc id. +* @irq: irq number. +* @suspended: qos operations. +*/ +struct fimc_context { +struct exynos_drm_ippdrv ippdrv; +struct resource *regs_res; +void __iomem *regs; +spinlock_t lock; +struct clk *sclk_fimc_clk; +struct clk *fimc_clk; +struct clk *wb_clk; +struct clk *wb_b_clk; +struct fimc_scaler sc; +struct fimc_capability *capa; +enum exynos_drm_fimc_ver ver; +struct exynos_drm_fimc_pol pol; +int id; +int irq; +bool suspended; +}; + +struct fimc_capability fimc51_capa[FIMC_MAX_DEVS ] = { + { + .in_hori =4224 , + .bypass =8192 , + .dst_h_wo_rot =4224 , + .dst_h_rot =1920 , + .rl_w_wo_rot =8192 , + .rl_h_rot =1920 , + }, { + .in_hori =4224 , + .bypass =8192 , + .dst_h_wo_rot =4224 , + .dst_h_rot =1920 , + .rl_w_wo_rot =8192 , + .rl_h_rot =1920 , + }, { + .in_hori =4224 , + .bypass =8192 , + .dst_h_wo_rot =4224 , + .dst_h_rot =1920 , + .rl_w_wo_rot =8192 , + .rl_h_rot =1920 , + }, { + .in_hori =1920 , + .bypass =8192 , + .dst_h_wo_rot =1920 , + .dst_h_rot =1366 , + .rl_w_wo_rot =8192 , + .rl_h_rot =1366 , + }, +}; + +static void fimc_sw_reset (struct fimc_context *ctx,bool pattern) +{ +u32 cfg; + +DRM_DEBUG_KMS ("%s:pattern[%d]\n" , __func__, pattern); + + cfg =fimc_read (EXYNOS_CISRCFMT ); + cfg |=EXYNOS_CISRCFMT_ITU601_8BIT ; +if (pattern) + cfg |=EXYNOS_CIGCTRL_TESTPATTERN_COLOR_BAR ; + +fimc_write (cfg,EXYNOS_CISRCFMT ); + +/* s/w reset */ + cfg =fimc_read (EXYNOS_CIGCTRL ); + cfg |= (EXYNOS_CIGCTRL_SWRST ); +fimc_write (cfg,EXYNOS_CIGCTRL ); + +/* s/w reset complete */ + cfg =fimc_read (EXYNOS_CIGCTRL ); + cfg &= ~EXYNOS_CIGCTRL_SWRST ; +fimc_write (cfg,EXYNOS_CIGCTRL ); + +/* reset sequence */ +fimc_write (0x0 ,EXYNOS_CIFCNTSEQ ); +} + +static void fimc_set_camblk_fimd0_wb (struct fimc_context *ctx) +{ +u32 camblk_cfg; + +DRM_DEBUG_KMS ("%s\n" , __func__); + + camblk_cfg =readl (SYSREG_CAMERA_BLK ); + camblk_cfg &= ~(SYSREG_FIMD0WB_DEST_MASK ); + camblk_cfg |= ctx->id << (SYSREG_FIMD0WB_DEST_SHIFT ); + +writel (camblk_cfg,SYSREG_CAMERA_BLK ); +} + +static void fimc_set_type_ctrl (struct fimc_context *ctx,enum fimc_wb wb) +{ +u32 cfg; + +DRM_DEBUG_KMS ("%s:wb[%d]\n" , __func__, wb); + + cfg =fimc_read (EXYNOS_CIGCTRL ); + cfg &= ~(EXYNOS_CIGCTRL_TESTPATTERN_MASK | +EXYNOS_CIGCTRL_SELCAM_ITU_MASK | +EXYNOS_CIGCTRL_SELCAM_MIPI_MASK | +EXYNOS_CIGCTRL_SELCAM_FIMC_MASK | +EXYNOS_CIGCTRL_SELWB_CAMIF_MASK | +EXYNOS_CIGCTRL_SELWRITEBACK_MASK ); + +switch (wb) { +case FIMC_WB_A : + cfg |= (EXYNOS_CIGCTRL_SELWRITEBACK_A | +EXYNOS_CIGCTRL_SELWB_CAMIF_WRITEBACK ); +break ; +case FIMC_WB_B : + cfg |= (EXYNOS_CIGCTRL_SELWRITEBACK_B | +EXYNOS_CIGCTRL_SELWB_CAMIF_WRITEBACK ); +break ; +case FIMC_WB_NONE : +default : + cfg |= (EXYNOS_CIGCTRL_SELCAM_ITU_A | +EXYNOS_CIGCTRL_SELWRITEBACK_A | +EXYNOS_CIGCTRL_SELCAM_MIPI_A | +EXYNOS_CIGCTRL_SELCAM_FIMC_ITU ); +break ; + } + +fimc_write (cfg,EXYNOS_CIGCTRL ); +} + +static void fimc_set_polarity (struct fimc_context *ctx, +struct exynos_drm_fimc_pol *pol) +{ +u32 cfg; + +DRM_DEBUG_KMS ("%s:inv_pclk[%d]inv_vsync[%d]\n" , + __func__, pol->inv_pclk, pol->inv_vsync); +DRM_DEBUG_KMS ("%s:inv_href[%d]inv_hsync[%d]\n" , + __func__, pol->inv_href, pol->inv_hsync); + + cfg =fimc_read (EXYNOS_CIGCTRL ); + cfg &= ~(EXYNOS_CIGCTRL_INVPOLPCLK |EXYNOS_CIGCTRL_INVPOLVSYNC | +EXYNOS_CIGCTRL_INVPOLHREF |EXYNOS_CIGCTRL_INVPOLHSYNC ); + +if (pol->inv_pclk) + cfg |=EXYNOS_CIGCTRL_INVPOLPCLK ; +if (pol->inv_vsync) + cfg |=EXYNOS_CIGCTRL_INVPOLVSYNC ; +if (pol->inv_href) + cfg |=EXYNOS_CIGCTRL_INVPOLHREF ; +if (pol->inv_hsync) + cfg |=EXYNOS_CIGCTRL_INVPOLHSYNC ; + +fimc_write (cfg,EXYNOS_CIGCTRL ); +} + +static void fimc_handle_jpeg (struct fimc_context *ctx,bool enable) +{ +u32 cfg; + +DRM_DEBUG_KMS ("%s:enable[%d]\n" , __func__, enable); + + cfg =fimc_read (EXYNOS_CIGCTRL ); +if (enable) + cfg |=EXYNOS_CIGCTRL_CAM_JPEG ; +else + cfg &= ~EXYNOS_CIGCTRL_CAM_JPEG ; + +fimc_write (cfg,EXYNOS_CIGCTRL ); +} + +static void fimc_handle_irq (struct fimc_context *ctx,bool enable, +bool overflow,bool level) +{ +u32 cfg; + +DRM_DEBUG_KMS ("%s:enable[%d]overflow[%d]level[%d]\n" , __func__, + enable, overflow, level); + + cfg =fimc_read (EXYNOS_CIGCTRL ); +if (enable) { + cfg &= ~(EXYNOS_CIGCTRL_IRQ_OVFEN |EXYNOS_CIGCTRL_IRQ_LEVEL ); + cfg |=EXYNOS_CIGCTRL_IRQ_ENABLE ; +if (overflow) + cfg |=EXYNOS_CIGCTRL_IRQ_OVFEN ; +if (level) + cfg |=EXYNOS_CIGCTRL_IRQ_LEVEL ; + }else + cfg &= ~(EXYNOS_CIGCTRL_IRQ_OVFEN |EXYNOS_CIGCTRL_IRQ_ENABLE ); + +fimc_write (cfg,EXYNOS_CIGCTRL ); +} + +static void fimc_clear_irq (struct fimc_context *ctx) +{ +u32 cfg; + +DRM_DEBUG_KMS ("%s\n" , __func__); + + cfg =fimc_read (EXYNOS_CIGCTRL ); + cfg |=EXYNOS_CIGCTRL_IRQ_CLR ; +fimc_write (cfg,EXYNOS_CIGCTRL ); +} + +static bool fimc_check_ovf (struct fimc_context *ctx) +{ +struct exynos_drm_ippdrv *ippdrv = &ctx->ippdrv; +u32 cfg, status, flag; + + status =fimc_read (EXYNOS_CISTATUS ); + flag =EXYNOS_CISTATUS_OVFIY |EXYNOS_CISTATUS_OVFICB | +EXYNOS_CISTATUS_OVFICR ; + +DRM_DEBUG_KMS ("%s:flag[0x%x]\n" , __func__, flag); + +if (status & flag) { + cfg =fimc_read (EXYNOS_CIWDOFST ); + cfg |= (EXYNOS_CIWDOFST_CLROVFIY |EXYNOS_CIWDOFST_CLROVFICB | +EXYNOS_CIWDOFST_CLROVFICR ); + +fimc_write (cfg,EXYNOS_CIWDOFST ); + + cfg =fimc_read (EXYNOS_CIWDOFST ); + cfg &= ~(EXYNOS_CIWDOFST_CLROVFIY |EXYNOS_CIWDOFST_CLROVFICB | +EXYNOS_CIWDOFST_CLROVFICR ); + +fimc_write (cfg,EXYNOS_CIWDOFST ); + +dev_err (ippdrv->dev,"occured overflow at %d, status 0x%x.\n" , + ctx->id, status); +return true; + } + +return false; +} + +static bool fimc_check_frame_end (struct fimc_context *ctx) +{ +u32 cfg; + + cfg =fimc_read (EXYNOS_CISTATUS ); + +DRM_DEBUG_KMS ("%s:cfg[0x%x]\n" , __func__, cfg); + +if (!(cfg &EXYNOS_CISTATUS_FRAMEEND )) +return false; + + cfg &= ~(EXYNOS_CISTATUS_FRAMEEND ); +fimc_write (cfg,EXYNOS_CISTATUS ); + +return true; +} + +static int fimc_get_buf_id (struct fimc_context *ctx) +{ +u32 cfg; +int frame_cnt, buf_id; + +DRM_DEBUG_KMS ("%s\n" , __func__); + + cfg =fimc_read (EXYNOS_CISTATUS2 ); + frame_cnt =EXYNOS_CISTATUS2_GET_FRAMECOUNT_BEFORE (cfg); + +if (frame_cnt ==0 ) + frame_cnt =EXYNOS_CISTATUS2_GET_FRAMECOUNT_PRESENT (cfg); + +DRM_DEBUG_KMS ("%s:present[%d]before[%d]\n" , __func__, +EXYNOS_CISTATUS2_GET_FRAMECOUNT_PRESENT (cfg), +EXYNOS_CISTATUS2_GET_FRAMECOUNT_BEFORE (cfg)); + +if (frame_cnt ==0 ) { +DRM_ERROR ("failed to get frame count.\n" ); +return -EIO ; + } + + buf_id = frame_cnt -1 ; +DRM_DEBUG_KMS ("%s:buf_id[%d]\n" , __func__, buf_id); + +return buf_id; +} + +static void fimc_handle_lastend (struct fimc_context *ctx,bool enable) +{ +u32 cfg; + +DRM_DEBUG_KMS ("%s:enable[%d]\n" , __func__, enable); + + cfg =fimc_read (EXYNOS_CIOCTRL ); +if (enable) + cfg |=EXYNOS_CIOCTRL_LASTENDEN ; +else + cfg &= ~EXYNOS_CIOCTRL_LASTENDEN ; + +fimc_write (cfg,EXYNOS_CIOCTRL ); +} + + +static int fimc_src_set_fmt_order (struct fimc_context *ctx,u32 fmt) +{ +struct exynos_drm_ippdrv *ippdrv = &ctx->ippdrv; +u32 cfg; + +DRM_DEBUG_KMS ("%s:fmt[0x%x]\n" , __func__, fmt); + +/* RGB */ + cfg =fimc_read (EXYNOS_CISCCTRL ); + cfg &= ~EXYNOS_CISCCTRL_INRGB_FMT_RGB_MASK ; + +switch (fmt) { +case DRM_FORMAT_RGB565 : + cfg |=EXYNOS_CISCCTRL_INRGB_FMT_RGB565 ; +fimc_write (cfg,EXYNOS_CISCCTRL ); +return 0 ; +case DRM_FORMAT_RGB888 : +case DRM_FORMAT_XRGB8888 : + cfg |=EXYNOS_CISCCTRL_INRGB_FMT_RGB888 ; +fimc_write (cfg,EXYNOS_CISCCTRL ); +return 0 ; +default : +/* bypass */ +break ; + } + +/* YUV */ + cfg =fimc_read (EXYNOS_MSCTRL ); + cfg &= ~(EXYNOS_MSCTRL_ORDER2P_SHIFT_MASK | +EXYNOS_MSCTRL_C_INT_IN_2PLANE | +EXYNOS_MSCTRL_ORDER422_YCBYCR ); + +switch (fmt) { +case DRM_FORMAT_YUYV : + cfg |=EXYNOS_MSCTRL_ORDER422_YCBYCR ; +break ; +case DRM_FORMAT_YVYU : + cfg |=EXYNOS_MSCTRL_ORDER422_YCRYCB ; +break ; +case DRM_FORMAT_UYVY : + cfg |=EXYNOS_MSCTRL_ORDER422_CBYCRY ; +break ; +case DRM_FORMAT_VYUY : +case DRM_FORMAT_YUV444 : + cfg |=EXYNOS_MSCTRL_ORDER422_CRYCBY ; +break ; +case DRM_FORMAT_NV21 : +case DRM_FORMAT_NV61 : + cfg |= (EXYNOS_MSCTRL_ORDER2P_LSB_CRCB | +EXYNOS_MSCTRL_C_INT_IN_2PLANE ); +break ; +case DRM_FORMAT_YUV422 : +case DRM_FORMAT_YUV420 : +case DRM_FORMAT_YVU420 : + cfg |=EXYNOS_MSCTRL_C_INT_IN_3PLANE ; +break ; +case DRM_FORMAT_NV12 : +case DRM_FORMAT_NV12MT : +case DRM_FORMAT_NV16 : + cfg |= (EXYNOS_MSCTRL_ORDER2P_LSB_CBCR | +EXYNOS_MSCTRL_C_INT_IN_2PLANE ); +break ; +default : +dev_err (ippdrv->dev,"inavlid source yuv order 0x%x.\n" , fmt); +return -EINVAL ; + } +
Quoted 8 lines
drivers/gpu/drm/exynos/exynos_drm_fimc.c line 483
Quoted 4 lines
drivers/gpu/drm/exynos/exynos_drm_fimc.c new file +4
-0+fimc_write (cfg,EXYNOS_MSCTRL ); + +return 0 ; +}This function is only called by
fimc_src_set_fmt()and both functions have routine to check format. There are also accessingEXYNOS_MSCTRL. So done those routine at one merged function can be helpful.
You are right. this function control same register. but format and ordering were separated. but relative register was same in source format. but destination format was different.
Quoted 355 lines
Quoted 355 lines
drivers/gpu/drm/exynos/exynos_drm_fimc.c new file +354
-0+ +static int fimc_src_set_fmt (struct device *dev,u32 fmt) +{ +struct fimc_context *ctx =get_fimc_context (dev); +struct exynos_drm_ippdrv *ippdrv = &ctx->ippdrv; +u32 cfg; + +DRM_DEBUG_KMS ("%s:fmt[0x%x]\n" , __func__, fmt); + + cfg =fimc_read (EXYNOS_MSCTRL ); + cfg &= ~EXYNOS_MSCTRL_INFORMAT_RGB ; + +switch (fmt) { +case DRM_FORMAT_RGB565 : +case DRM_FORMAT_RGB888 : +case DRM_FORMAT_XRGB8888 : + cfg |=EXYNOS_MSCTRL_INFORMAT_RGB ; +break ; +case DRM_FORMAT_YUV444 : + cfg |=EXYNOS_MSCTRL_INFORMAT_YCBCR420 ; +break ; +case DRM_FORMAT_YUYV : +case DRM_FORMAT_YVYU : +case DRM_FORMAT_UYVY : +case DRM_FORMAT_VYUY : + cfg |=EXYNOS_MSCTRL_INFORMAT_YCBCR422_1PLANE ; +break ; +case DRM_FORMAT_NV16 : +case DRM_FORMAT_NV61 : +case DRM_FORMAT_YUV422 : + cfg |=EXYNOS_MSCTRL_INFORMAT_YCBCR422 ; +break ; +case DRM_FORMAT_YUV420 : +case DRM_FORMAT_YVU420 : +case DRM_FORMAT_NV12 : +case DRM_FORMAT_NV21 : +case DRM_FORMAT_NV12MT : + cfg |=EXYNOS_MSCTRL_INFORMAT_YCBCR420 ; +break ; +default : +dev_err (ippdrv->dev,"inavlid source format 0x%x.\n" , fmt); +return -EINVAL ; + } + +fimc_write (cfg,EXYNOS_MSCTRL ); + + cfg =fimc_read (EXYNOS_CIDMAPARAM ); + cfg &= ~EXYNOS_CIDMAPARAM_R_MODE_MASK ; + +if (fmt ==DRM_FORMAT_NV12MT ) + cfg |=EXYNOS_CIDMAPARAM_R_MODE_64X32 ; +else + cfg |=EXYNOS_CIDMAPARAM_R_MODE_LINEAR ; + +fimc_write (cfg,EXYNOS_CIDMAPARAM ); + +return fimc_src_set_fmt_order (ctx, fmt); +} + +static int fimc_src_set_transf (struct device *dev, +enum drm_exynos_degree degree, +enum drm_exynos_flip flip) +{ +struct fimc_context *ctx =get_fimc_context (dev); +struct exynos_drm_ippdrv *ippdrv = &ctx->ippdrv; +u32 cfg1, cfg2; + +DRM_DEBUG_KMS ("%s:degree[%d]flip[0x%x]\n" , __func__, + degree, flip); + + cfg1 =fimc_read (EXYNOS_MSCTRL ); + cfg1 &= ~(EXYNOS_MSCTRL_FLIP_X_MIRROR | +EXYNOS_MSCTRL_FLIP_Y_MIRROR ); + + cfg2 =fimc_read (EXYNOS_CITRGFMT ); + cfg2 &= ~EXYNOS_CITRGFMT_INROT90_CLOCKWISE ; + +switch (degree) { +case EXYNOS_DRM_DEGREE_0 : +if (flip &EXYNOS_DRM_FLIP_HORIZONTAL ) + cfg1 |=EXYNOS_MSCTRL_FLIP_X_MIRROR ; +if (flip &EXYNOS_DRM_FLIP_VERTICAL ) + cfg1 |=EXYNOS_MSCTRL_FLIP_Y_MIRROR ; +break ; +case EXYNOS_DRM_DEGREE_90 : + cfg2 |=EXYNOS_CITRGFMT_INROT90_CLOCKWISE ; +if (flip &EXYNOS_DRM_FLIP_HORIZONTAL ) + cfg1 |=EXYNOS_MSCTRL_FLIP_X_MIRROR ; +if (flip &EXYNOS_DRM_FLIP_VERTICAL ) + cfg1 |=EXYNOS_MSCTRL_FLIP_Y_MIRROR ; +break ; +case EXYNOS_DRM_DEGREE_180 : + cfg1 |= (EXYNOS_MSCTRL_FLIP_X_MIRROR | +EXYNOS_MSCTRL_FLIP_Y_MIRROR ); +if (flip &EXYNOS_DRM_FLIP_HORIZONTAL ) + cfg1 &= ~EXYNOS_MSCTRL_FLIP_X_MIRROR ; +if (flip &EXYNOS_DRM_FLIP_VERTICAL ) + cfg1 &= ~EXYNOS_MSCTRL_FLIP_Y_MIRROR ; +break ; +case EXYNOS_DRM_DEGREE_270 : + cfg1 |= (EXYNOS_MSCTRL_FLIP_X_MIRROR | +EXYNOS_MSCTRL_FLIP_Y_MIRROR ); + cfg2 |=EXYNOS_CITRGFMT_INROT90_CLOCKWISE ; +if (flip &EXYNOS_DRM_FLIP_HORIZONTAL ) + cfg1 &= ~EXYNOS_MSCTRL_FLIP_X_MIRROR ; +if (flip &EXYNOS_DRM_FLIP_VERTICAL ) + cfg1 &= ~EXYNOS_MSCTRL_FLIP_Y_MIRROR ; +break ; +default : +dev_err (ippdrv->dev,"inavlid degree value %d.\n" , degree); +return -EINVAL ; + } + +fimc_write (cfg1,EXYNOS_MSCTRL ); +fimc_write (cfg2,EXYNOS_CITRGFMT ); + +return (cfg2 &EXYNOS_CITRGFMT_INROT90_CLOCKWISE ) ?1 :0 ; +} + +static int fimc_set_window (struct fimc_context *ctx, +struct drm_exynos_pos *pos,struct drm_exynos_sz *sz) +{ +u32 cfg, h1, h2, v1, v2; + +/* cropped image */ + h1 = pos->x; + h2 = sz->hsize - pos->w - pos->x; + v1 = pos->y; + v2 = sz->vsize - pos->h - pos->y; + +DRM_DEBUG_KMS ("%s:x[%d]y[%d]w[%d]h[%d]hsize[%d]vsize[%d]\n" , + __func__, pos->x, pos->y, pos->w, pos->h, sz->hsize, sz->vsize); +DRM_DEBUG_KMS ("%s:h1[%d]h2[%d]v1[%d]v2[%d]\n" , __func__, + h1, h2, v1, v2); + +/* +* set window offset 1, 2 size +* check figure 43-21 in user manual +*/ + cfg =fimc_read (EXYNOS_CIWDOFST ); + cfg &= ~(EXYNOS_CIWDOFST_WINHOROFST_MASK | +EXYNOS_CIWDOFST_WINVEROFST_MASK ); + cfg |= (EXYNOS_CIWDOFST_WINHOROFST (h1) | +EXYNOS_CIWDOFST_WINVEROFST (v1)); + cfg |=EXYNOS_CIWDOFST_WINOFSEN ; +fimc_write (cfg,EXYNOS_CIWDOFST ); + + cfg = (EXYNOS_CIWDOFST2_WINHOROFST2 (h2) | +EXYNOS_CIWDOFST2_WINVEROFST2 (v2)); +fimc_write (cfg,EXYNOS_CIWDOFST2 ); + +return 0 ; +} + +static int fimc_src_set_size (struct device *dev,int swap, +struct drm_exynos_pos *pos,struct drm_exynos_sz *sz) +{ +struct fimc_context *ctx =get_fimc_context (dev); +struct drm_exynos_pos img_pos = *pos; +struct drm_exynos_sz img_sz = *sz; +u32 cfg; + +/* ToDo: check width and height */ + +DRM_DEBUG_KMS ("%s:swap[%d]hsize[%d]vsize[%d]\n" , + __func__, swap, sz->hsize, sz->vsize); + +/* original size */ + cfg = (EXYNOS_ORGISIZE_HORIZONTAL (img_sz.hsize) | +EXYNOS_ORGISIZE_VERTICAL (img_sz.vsize)); + +fimc_write (cfg,EXYNOS_ORGISIZE ); + +DRM_DEBUG_KMS ("%s:x[%d]y[%d]w[%d]h[%d]\n" , __func__, + pos->x, pos->y, pos->w, pos->h); + +if (swap) { + img_pos.w = pos->h; + img_pos.h = pos->w; + img_sz.hsize = sz->vsize; + img_sz.vsize = sz->hsize; + } + +/* set input DMA image size */ + cfg =fimc_read (EXYNOS_CIREAL_ISIZE ); + cfg &= ~(EXYNOS_CIREAL_ISIZE_HEIGHT_MASK | +EXYNOS_CIREAL_ISIZE_WIDTH_MASK ); + cfg |= (EXYNOS_CIREAL_ISIZE_WIDTH (img_pos.w) | +EXYNOS_CIREAL_ISIZE_HEIGHT (img_pos.h)); +fimc_write (cfg,EXYNOS_CIREAL_ISIZE ); + +/* +* set input FIFO image size +* for now, we support only ITU601 8 bit mode +*/ + cfg = (EXYNOS_CISRCFMT_ITU601_8BIT | +EXYNOS_CISRCFMT_SOURCEHSIZE (img_sz.hsize) | +EXYNOS_CISRCFMT_SOURCEVSIZE (img_sz.vsize)); +fimc_write (cfg,EXYNOS_CISRCFMT ); + +/* offset Y(RGB), Cb, Cr */ + cfg = (EXYNOS_CIIYOFF_HORIZONTAL (img_pos.x) | +EXYNOS_CIIYOFF_VERTICAL (img_pos.y)); +fimc_write (cfg,EXYNOS_CIIYOFF ); + cfg = (EXYNOS_CIICBOFF_HORIZONTAL (img_pos.x) | +EXYNOS_CIICBOFF_VERTICAL (img_pos.y)); +fimc_write (cfg,EXYNOS_CIICBOFF ); + cfg = (EXYNOS_CIICROFF_HORIZONTAL (img_pos.x) | +EXYNOS_CIICROFF_VERTICAL (img_pos.y)); +fimc_write (cfg,EXYNOS_CIICROFF ); + +return fimc_set_window (ctx, &img_pos, &img_sz); +} + +static int fimc_src_set_addr (struct device *dev, +struct drm_exynos_ipp_buf_info *buf_info,u32 buf_id, +enum drm_exynos_ipp_buf_type buf_type) +{ +struct fimc_context *ctx =get_fimc_context (dev); +struct exynos_drm_ippdrv *ippdrv = &ctx->ippdrv; +struct drm_exynos_ipp_cmd_node *c_node = ippdrv->cmd; +struct drm_exynos_ipp_property *property; +struct drm_exynos_ipp_config *config; + +if (!c_node) { +DRM_ERROR ("failed to get c_node.\n" ); +return -EINVAL ; + } + + property = &c_node->property; +if (!property) { +DRM_ERROR ("failed to get property.\n" ); +return -EINVAL ; + } + +DRM_DEBUG_KMS ("%s:prop_id[%d]buf_id[%d]buf_type[%d]\n" , __func__, + property->prop_id, buf_id, buf_type); + +if (buf_id >FIMC_MAX_SRC ) { +dev_info (ippdrv->dev,"inavlid buf_id %d.\n" , buf_id); +return -ENOMEM ; + } + +/* address register set */ +switch (buf_type) { +case IPP_BUF_ENQUEUE : + config = &property->config[EXYNOS_DRM_OPS_SRC ]; +fimc_write (buf_info->base[EXYNOS_DRM_PLANAR_Y ], +EXYNOS_CIIYSA (buf_id)); + +if (config->fmt ==DRM_FORMAT_YVU420 ) { +fimc_write (buf_info->base[EXYNOS_DRM_PLANAR_CR ], +EXYNOS_CIICBSA (buf_id)); +fimc_write (buf_info->base[EXYNOS_DRM_PLANAR_CB ], +EXYNOS_CIICRSA (buf_id)); + }else { +fimc_write (buf_info->base[EXYNOS_DRM_PLANAR_CB ], +EXYNOS_CIICBSA (buf_id)); +fimc_write (buf_info->base[EXYNOS_DRM_PLANAR_CR ], +EXYNOS_CIICRSA (buf_id)); + } +break ; +case IPP_BUF_DEQUEUE : +fimc_write (0x0 ,EXYNOS_CIIYSA (buf_id)); +fimc_write (0x0 ,EXYNOS_CIICBSA (buf_id)); +fimc_write (0x0 ,EXYNOS_CIICRSA (buf_id)); +break ; +default : +/* bypass */ +break ; + } + +return 0 ; +} + +static struct exynos_drm_ipp_ops fimc_src_ops = { + .set_fmt = fimc_src_set_fmt, + .set_transf = fimc_src_set_transf, + .set_size = fimc_src_set_size, + .set_addr = fimc_src_set_addr, +}; + +static int fimc_dst_set_fmt_order (struct fimc_context *ctx,u32 fmt) +{ +struct exynos_drm_ippdrv *ippdrv = &ctx->ippdrv; +u32 cfg; + +DRM_DEBUG_KMS ("%s:fmt[0x%x]\n" , __func__, fmt); + +/* RGB */ + cfg =fimc_read (EXYNOS_CISCCTRL ); + cfg &= ~EXYNOS_CISCCTRL_OUTRGB_FMT_RGB_MASK ; + +switch (fmt) { +case DRM_FORMAT_RGB565 : + cfg |=EXYNOS_CISCCTRL_OUTRGB_FMT_RGB565 ; +fimc_write (cfg,EXYNOS_CISCCTRL ); +return 0 ; +case DRM_FORMAT_RGB888 : + cfg |=EXYNOS_CISCCTRL_OUTRGB_FMT_RGB888 ; +fimc_write (cfg,EXYNOS_CISCCTRL ); +return 0 ; +case DRM_FORMAT_XRGB8888 : + cfg |= (EXYNOS_CISCCTRL_OUTRGB_FMT_RGB888 | +EXYNOS_CISCCTRL_EXTRGB_EXTENSION ); +fimc_write (cfg,EXYNOS_CISCCTRL ); +break ; +default : +/* bypass */ +break ; + } + +/* YUV */ + cfg =fimc_read (EXYNOS_CIOCTRL ); + cfg &= ~(EXYNOS_CIOCTRL_ORDER2P_MASK | +EXYNOS_CIOCTRL_ORDER422_MASK | +EXYNOS_CIOCTRL_YCBCR_PLANE_MASK ); + +switch (fmt) { +case DRM_FORMAT_XRGB8888 : + cfg |=EXYNOS_CIOCTRL_ALPHA_OUT ; +break ; +case DRM_FORMAT_YUYV : + cfg |=EXYNOS_CIOCTRL_ORDER422_YCBYCR ; +break ; +case DRM_FORMAT_YVYU : + cfg |=EXYNOS_CIOCTRL_ORDER422_YCRYCB ; +break ; +case DRM_FORMAT_UYVY : + cfg |=EXYNOS_CIOCTRL_ORDER422_CBYCRY ; +break ; +case DRM_FORMAT_VYUY : + cfg |=EXYNOS_CIOCTRL_ORDER422_CRYCBY ; +break ; +case DRM_FORMAT_NV21 : +case DRM_FORMAT_NV61 : + cfg |=EXYNOS_CIOCTRL_ORDER2P_LSB_CRCB ; + cfg |=EXYNOS_CIOCTRL_YCBCR_2PLANE ; +break ; +case DRM_FORMAT_YUV422 : +case DRM_FORMAT_YUV420 : +case DRM_FORMAT_YVU420 : + cfg |=EXYNOS_CIOCTRL_YCBCR_3PLANE ; +break ; +case DRM_FORMAT_NV12 : +case DRM_FORMAT_NV12MT : +case DRM_FORMAT_NV16 : + cfg |=EXYNOS_CIOCTRL_ORDER2P_LSB_CBCR ; + cfg |=EXYNOS_CIOCTRL_YCBCR_2PLANE ; +break ; +default : +dev_err (ippdrv->dev,"inavlid target yuv order 0x%x.\n" , fmt); +return -EINVAL ; + }
Quoted 8 lines
drivers/gpu/drm/exynos/exynos_drm_fimc.c line 437
Quoted 5 lines
drivers/gpu/drm/exynos/exynos_drm_fimc.c new file +5
-0+ +fimc_write (cfg,EXYNOS_CIOCTRL ); + +return 0 ; +}This function is also only called by
fimc_dst_set_fmtand both functions have format check. So ther can be merged into one function.
This function controled difference register. so, I think this case is no problem. If we merge this routine. than we got the all seperated "switch case" routine. complexity has increased, and function line count very increased. :)
Quoted 1,203 lines
Quoted 1,200 lines
drivers/gpu/drm/exynos/exynos_drm_fimc.c new file +1199
-0+ +static int fimc_dst_set_fmt (struct device *dev,u32 fmt) +{ +struct fimc_context *ctx =get_fimc_context (dev); +struct exynos_drm_ippdrv *ippdrv = &ctx->ippdrv; +u32 cfg; + +DRM_DEBUG_KMS ("%s:fmt[0x%x]\n" , __func__, fmt); + + cfg =fimc_read (EXYNOS_CIEXTEN ); + +if (fmt ==DRM_FORMAT_AYUV ) { + cfg |=EXYNOS_CIEXTEN_YUV444_OUT ; +fimc_write (cfg,EXYNOS_CIEXTEN ); + }else { + cfg &= ~EXYNOS_CIEXTEN_YUV444_OUT ; +fimc_write (cfg,EXYNOS_CIEXTEN ); + + cfg =fimc_read (EXYNOS_CITRGFMT ); + cfg &= ~EXYNOS_CITRGFMT_OUTFORMAT_MASK ; + +switch (fmt) { +case DRM_FORMAT_RGB565 : +case DRM_FORMAT_RGB888 : +case DRM_FORMAT_XRGB8888 : + cfg |=EXYNOS_CITRGFMT_OUTFORMAT_RGB ; +break ; +case DRM_FORMAT_YUYV : +case DRM_FORMAT_YVYU : +case DRM_FORMAT_UYVY : +case DRM_FORMAT_VYUY : + cfg |=EXYNOS_CITRGFMT_OUTFORMAT_YCBCR422_1PLANE ; +break ; +case DRM_FORMAT_NV16 : +case DRM_FORMAT_NV61 : +case DRM_FORMAT_YUV422 : + cfg |=EXYNOS_CITRGFMT_OUTFORMAT_YCBCR422 ; +break ; +case DRM_FORMAT_YUV420 : +case DRM_FORMAT_YVU420 : +case DRM_FORMAT_NV12 : +case DRM_FORMAT_NV12MT : +case DRM_FORMAT_NV21 : + cfg |=EXYNOS_CITRGFMT_OUTFORMAT_YCBCR420 ; +break ; +default : +dev_err (ippdrv->dev,"inavlid target format 0x%x.\n" , + fmt); +return -EINVAL ; + } + +fimc_write (cfg,EXYNOS_CITRGFMT ); + } + + cfg =fimc_read (EXYNOS_CIDMAPARAM ); + cfg &= ~EXYNOS_CIDMAPARAM_W_MODE_MASK ; + +if (fmt ==DRM_FORMAT_NV12MT ) + cfg |=EXYNOS_CIDMAPARAM_W_MODE_64X32 ; +else + cfg |=EXYNOS_CIDMAPARAM_W_MODE_LINEAR ; + +fimc_write (cfg,EXYNOS_CIDMAPARAM ); + +return fimc_dst_set_fmt_order (ctx, fmt); +} + +static int fimc_dst_set_transf (struct device *dev, +enum drm_exynos_degree degree, +enum drm_exynos_flip flip) +{ +struct fimc_context *ctx =get_fimc_context (dev); +struct exynos_drm_ippdrv *ippdrv = &ctx->ippdrv; +u32 cfg; + +DRM_DEBUG_KMS ("%s:degree[%d]flip[0x%x]\n" , __func__, + degree, flip); + + cfg =fimc_read (EXYNOS_CITRGFMT ); + cfg &= ~EXYNOS_CITRGFMT_FLIP_MASK ; + cfg &= ~EXYNOS_CITRGFMT_OUTROT90_CLOCKWISE ; + +switch (degree) { +case EXYNOS_DRM_DEGREE_0 : +if (flip &EXYNOS_DRM_FLIP_HORIZONTAL ) + cfg |=EXYNOS_CITRGFMT_FLIP_X_MIRROR ; +if (flip &EXYNOS_DRM_FLIP_VERTICAL ) + cfg |=EXYNOS_CITRGFMT_FLIP_Y_MIRROR ; +break ; +case EXYNOS_DRM_DEGREE_90 : + cfg |=EXYNOS_CITRGFMT_OUTROT90_CLOCKWISE ; +if (flip &EXYNOS_DRM_FLIP_HORIZONTAL ) + cfg |=EXYNOS_CITRGFMT_FLIP_X_MIRROR ; +if (flip &EXYNOS_DRM_FLIP_VERTICAL ) + cfg |=EXYNOS_CITRGFMT_FLIP_Y_MIRROR ; +break ; +case EXYNOS_DRM_DEGREE_180 : + cfg |= (EXYNOS_CITRGFMT_FLIP_X_MIRROR | +EXYNOS_CITRGFMT_FLIP_Y_MIRROR ); +if (flip &EXYNOS_DRM_FLIP_HORIZONTAL ) + cfg &= ~EXYNOS_CITRGFMT_FLIP_X_MIRROR ; +if (flip &EXYNOS_DRM_FLIP_VERTICAL ) + cfg &= ~EXYNOS_CITRGFMT_FLIP_Y_MIRROR ; +break ; +case EXYNOS_DRM_DEGREE_270 : + cfg |= (EXYNOS_CITRGFMT_OUTROT90_CLOCKWISE | +EXYNOS_CITRGFMT_FLIP_X_MIRROR | +EXYNOS_CITRGFMT_FLIP_Y_MIRROR ); +if (flip &EXYNOS_DRM_FLIP_HORIZONTAL ) + cfg &= ~EXYNOS_CITRGFMT_FLIP_X_MIRROR ; +if (flip &EXYNOS_DRM_FLIP_VERTICAL ) + cfg &= ~EXYNOS_CITRGFMT_FLIP_Y_MIRROR ; +break ; +default : +dev_err (ippdrv->dev,"inavlid degree value %d.\n" , degree); +return -EINVAL ; + } + +fimc_write (cfg,EXYNOS_CITRGFMT ); + +return (cfg &EXYNOS_CITRGFMT_OUTROT90_CLOCKWISE ) ?1 :0 ; +} + +static int fimc_get_ratio_shift (u32 src,u32 dst,u32 *ratio,u32 *shift) +{ +DRM_DEBUG_KMS ("%s:src[%d]dst[%d]\n" , __func__, src, dst); + +if (src >= dst *64 ) { +DRM_ERROR ("failed to make ratio and shift.\n" ); +return -EINVAL ; + }else if (src >= dst *32 ) { + *ratio =32 ; + *shift =5 ; + }else if (src >= dst *16 ) { + *ratio =16 ; + *shift =4 ; + }else if (src >= dst *8 ) { + *ratio =8 ; + *shift =3 ; + }else if (src >= dst *4 ) { + *ratio =4 ; + *shift =2 ; + }else if (src >= dst *2 ) { + *ratio =2 ; + *shift =1 ; + }else { + *ratio =1 ; + *shift =0 ; + } + +return 0 ; +} + +static int fimc_set_prescaler (struct fimc_context *ctx,struct fimc_scaler *sc, +struct drm_exynos_pos *src,struct drm_exynos_pos *dst) +{ +struct exynos_drm_ippdrv *ippdrv = &ctx->ippdrv; +u32 cfg, cfg_ext, shfactor; +u32 pre_dst_width, pre_dst_height; +u32 pre_hratio, hfactor, pre_vratio, vfactor; +int ret =0 ; +u32 src_w, src_h, dst_w, dst_h; + + cfg_ext =fimc_read (EXYNOS_CITRGFMT ); +if (cfg_ext &EXYNOS_CITRGFMT_INROT90_CLOCKWISE ) { + src_w = src->h; + src_h = src->w; + }else { + src_w = src->w; + src_h = src->h; + } + +if (cfg_ext &EXYNOS_CITRGFMT_OUTROT90_CLOCKWISE ) { + dst_w = dst->h; + dst_h = dst->w; + }else { + dst_w = dst->w; + dst_h = dst->h; + } + + ret =fimc_get_ratio_shift (src_w, dst_w, &pre_hratio, &hfactor); +if (ret) { +dev_err (ippdrv->dev,"failed to get ratio horizontal.\n" ); +return ret; + } + + ret =fimc_get_ratio_shift (src_h, dst_h, &pre_vratio, &vfactor); +if (ret) { +dev_err (ippdrv->dev,"failed to get ratio vertical.\n" ); +return ret; + } + + pre_dst_width = src_w / pre_hratio; + pre_dst_height = src_h / pre_vratio; +DRM_DEBUG_KMS ("%s:pre_dst_width[%d]pre_dst_height[%d]\n" , __func__, + pre_dst_width, pre_dst_height); +DRM_DEBUG_KMS ("%s:pre_hratio[%d]hfactor[%d]pre_vratio[%d]vfactor[%d]\n" , + __func__, pre_hratio, hfactor, pre_vratio, vfactor); + + sc->hratio = (src_w <<14 ) / (dst_w << hfactor); + sc->vratio = (src_h <<14 ) / (dst_h << vfactor); + sc->up_h = (dst_w >= src_w) ? true : false; + sc->up_v = (dst_h >= src_h) ? true : false; +DRM_DEBUG_KMS ("%s:hratio[%d]vratio[%d]up_h[%d]up_v[%d]\n" , + __func__, sc->hratio, sc->vratio, sc->up_h, sc->up_v); + + shfactor =10 - (hfactor + vfactor); +DRM_DEBUG_KMS ("%s:shfactor[%d]\n" , __func__, shfactor); + + cfg = (EXYNOS_CISCPRERATIO_SHFACTOR (shfactor) | +EXYNOS_CISCPRERATIO_PREHORRATIO (pre_hratio) | +EXYNOS_CISCPRERATIO_PREVERRATIO (pre_vratio)); +fimc_write (cfg,EXYNOS_CISCPRERATIO ); + + cfg = (EXYNOS_CISCPREDST_PREDSTWIDTH (pre_dst_width) | +EXYNOS_CISCPREDST_PREDSTHEIGHT (pre_dst_height)); +fimc_write (cfg,EXYNOS_CISCPREDST ); + +return ret; +} + +static void fimc_set_scaler (struct fimc_context *ctx,struct fimc_scaler *sc) +{ +u32 cfg, cfg_ext; + +DRM_DEBUG_KMS ("%s:range[%d]bypass[%d]up_h[%d]up_v[%d]\n" , + __func__, sc->range, sc->bypass, sc->up_h, sc->up_v); +DRM_DEBUG_KMS ("%s:hratio[%d]vratio[%d]\n" , + __func__, sc->hratio, sc->vratio); + + cfg =fimc_read (EXYNOS_CISCCTRL ); + cfg &= ~(EXYNOS_CISCCTRL_SCALERBYPASS | +EXYNOS_CISCCTRL_SCALEUP_H |EXYNOS_CISCCTRL_SCALEUP_V | +EXYNOS_CISCCTRL_MAIN_V_RATIO_MASK | +EXYNOS_CISCCTRL_MAIN_H_RATIO_MASK | +EXYNOS_CISCCTRL_CSCR2Y_WIDE | +EXYNOS_CISCCTRL_CSCY2R_WIDE ); + +if (sc->range) + cfg |= (EXYNOS_CISCCTRL_CSCR2Y_WIDE | +EXYNOS_CISCCTRL_CSCY2R_WIDE ); +if (sc->bypass) + cfg |=EXYNOS_CISCCTRL_SCALERBYPASS ; +if (sc->up_h) + cfg |=EXYNOS_CISCCTRL_SCALEUP_H ; +if (sc->up_v) + cfg |=EXYNOS_CISCCTRL_SCALEUP_V ; + + cfg |= (EXYNOS_CISCCTRL_MAINHORRATIO ((sc->hratio >>6 )) | +EXYNOS_CISCCTRL_MAINVERRATIO ((sc->vratio >>6 ))); +fimc_write (cfg,EXYNOS_CISCCTRL ); + + cfg_ext =fimc_read (EXYNOS_CIEXTEN ); + cfg_ext &= ~EXYNOS_CIEXTEN_MAINHORRATIO_EXT_MASK ; + cfg_ext &= ~EXYNOS_CIEXTEN_MAINVERRATIO_EXT_MASK ; + cfg_ext |= (EXYNOS_CIEXTEN_MAINHORRATIO_EXT (sc->hratio) | +EXYNOS_CIEXTEN_MAINVERRATIO_EXT (sc->vratio)); +fimc_write (cfg_ext,EXYNOS_CIEXTEN ); +} + +static int fimc_dst_set_size (struct device *dev,int swap, +struct drm_exynos_pos *pos,struct drm_exynos_sz *sz) +{ +struct fimc_context *ctx =get_fimc_context (dev); +struct drm_exynos_pos img_pos = *pos; +struct drm_exynos_sz img_sz = *sz; +u32 cfg; + +DRM_DEBUG_KMS ("%s:swap[%d]hsize[%d]vsize[%d]\n" , + __func__, swap, sz->hsize, sz->vsize); + +/* original size */ + cfg = (EXYNOS_ORGOSIZE_HORIZONTAL (img_sz.hsize) | +EXYNOS_ORGOSIZE_VERTICAL (img_sz.vsize)); + +fimc_write (cfg,EXYNOS_ORGOSIZE ); + +DRM_DEBUG_KMS ("%s:x[%d]y[%d]w[%d]h[%d]\n" , + __func__, pos->x, pos->y, pos->w, pos->h); + +/* CSC ITU */ + cfg =fimc_read (EXYNOS_CIGCTRL ); + cfg &= ~EXYNOS_CIGCTRL_CSC_MASK ; + +if (sz->hsize >=FIMC_WIDTH_ITU_709 ) + cfg |=EXYNOS_CIGCTRL_CSC_ITU709 ; +else + cfg |=EXYNOS_CIGCTRL_CSC_ITU601 ; + +fimc_write (cfg,EXYNOS_CIGCTRL ); + +if (swap) { + img_pos.w = pos->h; + img_pos.h = pos->w; + img_sz.hsize = sz->vsize; + img_sz.vsize = sz->hsize; + } + +/* target image size */ + cfg =fimc_read (EXYNOS_CITRGFMT ); + cfg &= ~(EXYNOS_CITRGFMT_TARGETH_MASK | +EXYNOS_CITRGFMT_TARGETV_MASK ); + cfg |= (EXYNOS_CITRGFMT_TARGETHSIZE (img_pos.w) | +EXYNOS_CITRGFMT_TARGETVSIZE (img_pos.h)); +fimc_write (cfg,EXYNOS_CITRGFMT ); + +/* target area */ + cfg =EXYNOS_CITAREA_TARGET_AREA (img_pos.w * img_pos.h); +fimc_write (cfg,EXYNOS_CITAREA ); + +/* ToDo: Move Scaler in this line and YUV */ + +/* offset Y(RGB), Cb, Cr */ + cfg = (EXYNOS_CIOYOFF_HORIZONTAL (img_pos.x) | +EXYNOS_CIOYOFF_VERTICAL (img_pos.y)); +fimc_write (cfg,EXYNOS_CIOYOFF ); + cfg = (EXYNOS_CIOCBOFF_HORIZONTAL (img_pos.x) | +EXYNOS_CIOCBOFF_VERTICAL (img_pos.y)); +fimc_write (cfg,EXYNOS_CIOCBOFF ); + cfg = (EXYNOS_CIOCROFF_HORIZONTAL (img_pos.x) | +EXYNOS_CIOCROFF_VERTICAL (img_pos.y)); +fimc_write (cfg,EXYNOS_CIOCROFF ); + +return 0 ; +} + +static int fimc_dst_get_buf_seq (struct fimc_context *ctx) +{ +u32 cfg, i, buf_num =0 ; +u32 mask =0x00000001 ; + + cfg =fimc_read (EXYNOS_CIFCNTSEQ ); + +for (i =0 ; i <FIMC_REG_SZ ; i++) +if (cfg & (mask << i)) + buf_num++; + +DRM_DEBUG_KMS ("%s:buf_num[%d]\n" , __func__, buf_num); + +return buf_num; +} + +static int fimc_dst_set_buf_seq (struct fimc_context *ctx,u32 buf_id, +enum drm_exynos_ipp_buf_type buf_type) +{ +struct exynos_drm_ippdrv *ippdrv = &ctx->ippdrv; +bool enable; +u32 cfg; +u32 mask =0x00000001 << buf_id; +unsigned long flags; +int ret =0 ; + +DRM_DEBUG_KMS ("%s:buf_id[%d]buf_type[%d]\n" , __func__, + buf_id, buf_type); + +spin_lock_irqsave (&ctx->lock, flags); + +/* mask register set */ + cfg =fimc_read (EXYNOS_CIFCNTSEQ ); + +switch (buf_type) { +case IPP_BUF_ENQUEUE : + enable = true; +break ; +case IPP_BUF_DEQUEUE : + enable = false; +break ; +default : +dev_err (ippdrv->dev,"invalid buf ctrl parameter.\n" ); + ret = -EINVAL ; + goto err_unlock; + } + +/* sequence id */ + cfg &= (~mask); + cfg |= (enable << buf_id); +fimc_write (cfg,EXYNOS_CIFCNTSEQ ); + +/* interrupt enable */ +if (buf_type ==IPP_BUF_ENQUEUE && +fimc_dst_get_buf_seq (ctx) >=FIMC_BUF_START ) +fimc_handle_irq (ctx, true, false, true); + +/* interrupt disable */ +if (buf_type ==IPP_BUF_DEQUEUE && +fimc_dst_get_buf_seq (ctx) <=FIMC_BUF_STOP ) +fimc_handle_irq (ctx, false, false, true); + +err_unlock: +spin_unlock_irqrestore (&ctx->lock, flags); +return ret; +} + +static int fimc_dst_set_addr (struct device *dev, +struct drm_exynos_ipp_buf_info *buf_info,u32 buf_id, +enum drm_exynos_ipp_buf_type buf_type) +{ +struct fimc_context *ctx =get_fimc_context (dev); +struct exynos_drm_ippdrv *ippdrv = &ctx->ippdrv; +struct drm_exynos_ipp_cmd_node *c_node = ippdrv->cmd; +struct drm_exynos_ipp_property *property; +struct drm_exynos_ipp_config *config; + +if (!c_node) { +DRM_ERROR ("failed to get c_node.\n" ); +return -EINVAL ; + } + + property = &c_node->property; +if (!property) { +DRM_ERROR ("failed to get property.\n" ); +return -EINVAL ; + } + +DRM_DEBUG_KMS ("%s:prop_id[%d]buf_id[%d]buf_type[%d]\n" , __func__, + property->prop_id, buf_id, buf_type); + +if (buf_id >FIMC_MAX_DST ) { +dev_info (ippdrv->dev,"inavlid buf_id %d.\n" , buf_id); +return -ENOMEM ; + } + +/* address register set */ +switch (buf_type) { +case IPP_BUF_ENQUEUE : + config = &property->config[EXYNOS_DRM_OPS_DST ]; + +fimc_write (buf_info->base[EXYNOS_DRM_PLANAR_Y ], +EXYNOS_CIOYSA (buf_id)); + +if (config->fmt ==DRM_FORMAT_YVU420 ) { +fimc_write (buf_info->base[EXYNOS_DRM_PLANAR_CR ], +EXYNOS_CIOCBSA (buf_id)); +fimc_write (buf_info->base[EXYNOS_DRM_PLANAR_CB ], +EXYNOS_CIOCRSA (buf_id)); + }else { +fimc_write (buf_info->base[EXYNOS_DRM_PLANAR_CB ], +EXYNOS_CIOCBSA (buf_id)); +fimc_write (buf_info->base[EXYNOS_DRM_PLANAR_CR ], +EXYNOS_CIOCRSA (buf_id)); + } +break ; +case IPP_BUF_DEQUEUE : +fimc_write (0x0 ,EXYNOS_CIOYSA (buf_id)); +fimc_write (0x0 ,EXYNOS_CIOCBSA (buf_id)); +fimc_write (0x0 ,EXYNOS_CIOCRSA (buf_id)); +break ; +default : +/* bypass */ +break ; + } + +return fimc_dst_set_buf_seq (ctx, buf_id, buf_type); +} + +static struct exynos_drm_ipp_ops fimc_dst_ops = { + .set_fmt = fimc_dst_set_fmt, + .set_transf = fimc_dst_set_transf, + .set_size = fimc_dst_set_size, + .set_addr = fimc_dst_set_addr, +}; + +static int fimc_power_on (struct fimc_context *ctx,bool enable) +{ +struct exynos_drm_ippdrv *ippdrv = &ctx->ippdrv; + +DRM_DEBUG_KMS ("%s:enable[%d]\n" , __func__, enable); + +if (enable) { +if (ctx->ver ==FIMC_EXYNOS_4210 ) { + ctx->sclk_fimc_clk =clk_get (ippdrv->dev,"sclk_fimc" ); +if (IS_ERR (ctx->sclk_fimc_clk)) { +dev_err (ippdrv->dev,"failed to get src fimc clock.\n" ); +return -EINVAL ; + } +clk_enable (ctx->sclk_fimc_clk); + }else +clk_enable (ctx->sclk_fimc_clk); + +clk_enable (ctx->fimc_clk); +clk_enable (ctx->wb_clk); +/* ToDo : wb_b_clk */ + ctx->suspended = false; + }else { +clk_disable (ctx->sclk_fimc_clk); +clk_disable (ctx->fimc_clk); +clk_disable (ctx->wb_clk); +/* ToDo : wb_b_clk */ + ctx->suspended = true; + } + +return 0 ; +} + +static irqreturn_t fimc_irq_handler (int irq,void *dev_id) +{ +struct fimc_context *ctx = dev_id; +struct exynos_drm_ippdrv *ippdrv = &ctx->ippdrv; +struct drm_exynos_ipp_cmd_node *c_node = ippdrv->cmd; +struct drm_exynos_ipp_event_work *event_work = + c_node->event_work; +int buf_id; + +DRM_DEBUG_KMS ("%s:fimc id[%d]\n" , __func__, ctx->id); + +fimc_clear_irq (ctx); +if (fimc_check_ovf (ctx)) +return IRQ_NONE ; + +if (!fimc_check_frame_end (ctx)) +return IRQ_NONE ; + + buf_id =fimc_get_buf_id (ctx); +if (buf_id <0 ) +return IRQ_HANDLED ; + +DRM_DEBUG_KMS ("%s:buf_id[%d]\n" , __func__, buf_id); + +if (fimc_dst_set_buf_seq (ctx, buf_id,IPP_BUF_DEQUEUE ) <0 ) { +DRM_ERROR ("failed to dequeue.\n" ); +return IRQ_HANDLED ; + } + + event_work->ippdrv = ippdrv; + event_work->buf_id[EXYNOS_DRM_OPS_DST ] = buf_id; +queue_work (ippdrv->event_workq, (struct work_struct *)event_work); + +return IRQ_HANDLED ; +} + +static int fimc_init_prop_list (struct drm_exynos_ipp_prop_list **prop_list) +{ +DRM_DEBUG_KMS ("%s\n" , __func__); + +if (!prop_list) { +DRM_ERROR ("empty prop_list\n" ); +return -EINVAL ; + } + + *prop_list =kzalloc (sizeof (**prop_list),GFP_KERNEL ); +if (!*prop_list) { +DRM_ERROR ("failed to alloc property list.\n" ); +return -ENOMEM ; + } +/*ToDo : fix supported function list*/ + (*prop_list)->version =1 ; + (*prop_list)->writeback =1 ; + (*prop_list)->refresh_min =12 ; + (*prop_list)->refresh_max =60 ; + (*prop_list)->flip = (1 <<EXYNOS_DRM_FLIP_NONE ) | + (1 <<EXYNOS_DRM_FLIP_VERTICAL ) | + (1 <<EXYNOS_DRM_FLIP_HORIZONTAL ); + (*prop_list)->degree = (1 <<EXYNOS_DRM_DEGREE_0 ) | + (1 <<EXYNOS_DRM_DEGREE_90 ) | + (1 <<EXYNOS_DRM_DEGREE_180 ) | + (1 <<EXYNOS_DRM_DEGREE_270 ); + (*prop_list)->csc =1 ; + (*prop_list)->crop =1 ; + (*prop_list)->crop_max.hsize =8192 ; + (*prop_list)->crop_max.vsize =8192 ; + (*prop_list)->crop_min.hsize =32 ; + (*prop_list)->crop_min.vsize =32 ; + (*prop_list)->scale =1 ; + (*prop_list)->scale_max.hsize =4224 ; + (*prop_list)->scale_max.vsize =4224 ; + (*prop_list)->scale_min.hsize =32 ; + (*prop_list)->scale_min.vsize =32 ; + +return 0 ; +} + +static int fimc_ippdrv_check_property (struct device *dev, +struct drm_exynos_ipp_property *property) +{ +struct fimc_context *ctx =get_fimc_context (dev); +struct exynos_drm_ippdrv *ippdrv = &ctx->ippdrv; +struct drm_exynos_ipp_prop_list *pp = ippdrv->prop_list; +struct drm_exynos_ipp_config *config; +struct drm_exynos_pos *pos; +struct drm_exynos_sz *sz; +bool swap; +int i; + +DRM_DEBUG_KMS ("%s\n" , __func__); + +for_each_ipp_ops (i) { +if ((i ==EXYNOS_DRM_OPS_SRC ) && + (property->cmd ==IPP_CMD_WB )) +continue ; + + config = &property->config[i]; + pos = &config->pos; + sz = &config->sz; + +/* check for flip */ +switch (config->flip) { +case EXYNOS_DRM_FLIP_NONE : +case EXYNOS_DRM_FLIP_VERTICAL : +case EXYNOS_DRM_FLIP_HORIZONTAL : +/* No problem */ +break ; +default : +DRM_ERROR ("invalid flip.\n" ); + goto err_property; + } + +/* check for degree */ +switch (config->degree) { +case EXYNOS_DRM_DEGREE_90 : +case EXYNOS_DRM_DEGREE_270 : + swap = true; +break ; +case EXYNOS_DRM_DEGREE_0 : +case EXYNOS_DRM_DEGREE_180 : + swap = false; +break ; +default : +DRM_ERROR ("invalid degree.\n" ); + goto err_property; + } + +/* check for buffer bound */ +if ((pos->x + pos->w > sz->hsize) || + (pos->y + pos->h > sz->vsize)) { +DRM_ERROR ("out of buf bound.\n" ); + goto err_property; + } + +/* check for crop */ +if ((i ==EXYNOS_DRM_OPS_SRC ) && (pp->crop)) { +if (swap) { +if ((pos->h < pp->crop_min.hsize) || + (sz->vsize > pp->crop_max.hsize) || + (pos->w < pp->crop_min.vsize) || + (sz->hsize > pp->crop_max.vsize)) { +DRM_ERROR ("out of crop size.\n" ); + goto err_property; + } + }else { +if ((pos->w < pp->crop_min.hsize) || + (sz->hsize > pp->crop_max.hsize) || + (pos->h < pp->crop_min.vsize) || + (sz->vsize > pp->crop_max.vsize)) { +DRM_ERROR ("out of crop size.\n" ); + goto err_property; + } + } + } + +/* check for scale */ +if ((i ==EXYNOS_DRM_OPS_DST ) && (pp->scale)) { +if (swap) { +if ((pos->h < pp->scale_min.hsize) || + (sz->vsize > pp->scale_max.hsize) || + (pos->w < pp->scale_min.vsize) || + (sz->hsize > pp->scale_max.vsize)) { +DRM_ERROR ("out of scale size.\n" ); + goto err_property; + } + }else { +if ((pos->w < pp->scale_min.hsize) || + (sz->hsize > pp->scale_max.hsize) || + (pos->h < pp->scale_min.vsize) || + (sz->vsize > pp->scale_max.vsize)) { +DRM_ERROR ("out of scale size.\n" ); + goto err_property; + } + } + } + } + +return 0 ; + +err_property: +for_each_ipp_ops (i) { +if ((i ==EXYNOS_DRM_OPS_SRC ) && + (property->cmd ==IPP_CMD_WB )) +continue ; + + config = &property->config[i]; + pos = &config->pos; + sz = &config->sz; + +DRM_ERROR ("[%s]f[%d]r[%d]pos[%d %d %d %d]sz[%d %d]\n" , + i ?"dst" :"src" , config->flip, config->degree, + pos->x, pos->y, pos->w, pos->h, + sz->hsize, sz->vsize); + } + +return -EINVAL ; +} + +static int fimc_ippdrv_reset (struct device *dev) +{ +struct fimc_context *ctx =get_fimc_context (dev); + +DRM_DEBUG_KMS ("%s\n" , __func__); + +/* reset h/w block */ +fimc_sw_reset (ctx, false); + +/* reset scaler capability */ +memset (&ctx->sc,0x0 ,sizeof (ctx->sc)); + +return 0 ; +} + +static int fimc_check_prepare (struct fimc_context *ctx) +{ +/* ToDo: check prepare using read register */ +DRM_DEBUG_KMS ("%s\n" , __func__); + +return 0 ; +} + +static int fimc_ippdrv_start (struct device *dev,enum drm_exynos_ipp_cmd cmd) +{ +struct fimc_context *ctx =get_fimc_context (dev); +struct exynos_drm_ippdrv *ippdrv = &ctx->ippdrv; +struct drm_exynos_ipp_cmd_node *c_node = ippdrv->cmd; +struct drm_exynos_ipp_property *property; +struct drm_exynos_ipp_config *config; +struct drm_exynos_pos img_pos[EXYNOS_DRM_OPS_MAX ]; +struct drm_exynos_ipp_set_wb set_wb; +int ret, i; +u32 cfg0, cfg1; + +DRM_DEBUG_KMS ("%s:cmd[%d]\n" , __func__, cmd); + +if (!c_node) { +DRM_ERROR ("failed to get c_node.\n" ); +return -EINVAL ; + } + + property = &c_node->property; +if (!property) { +DRM_ERROR ("failed to get property.\n" ); +return -EINVAL ; + } + + ret =fimc_check_prepare (ctx); +if (ret) { +dev_err (dev,"failed to check prepare.\n" ); +return ret; + } + +fimc_handle_irq (ctx, true, false, true); + +/* ToDo: window size, prescaler config */ +for_each_ipp_ops (i) { + config = &property->config[i]; + img_pos[i] = config->pos; + } + + ret =fimc_set_prescaler (ctx, &ctx->sc, + &img_pos[EXYNOS_DRM_OPS_SRC ], + &img_pos[EXYNOS_DRM_OPS_DST ]); +if (ret) { +dev_err (dev,"failed to set precalser.\n" ); +return ret; + } + +/* If set ture, we can save jpeg about screen */ +fimc_handle_jpeg (ctx, false); +fimc_set_scaler (ctx, &ctx->sc); +fimc_set_polarity (ctx, &ctx->pol); + +switch (cmd) { +case IPP_CMD_M2M : +fimc_set_type_ctrl (ctx,FIMC_WB_NONE ); +fimc_handle_lastend (ctx, false); + +/* setup dma */ + cfg0 =fimc_read (EXYNOS_MSCTRL ); + cfg0 &= ~EXYNOS_MSCTRL_INPUT_MASK ; + cfg0 |=EXYNOS_MSCTRL_INPUT_MEMORY ; +fimc_write (cfg0,EXYNOS_MSCTRL ); +break ; +case IPP_CMD_WB : +fimc_set_type_ctrl (ctx,FIMC_WB_A ); +fimc_handle_lastend (ctx, true); + +/* setup FIMD */ +fimc_set_camblk_fimd0_wb (ctx); + +/* ToDo: need to replace the property structure. */ + set_wb.enable =1 ; + set_wb.refresh = property->reserved; +exynos_drm_ippnb_send_event (IPP_SET_WRITEBACK , (void *)&set_wb); +break ; +case IPP_CMD_OUTPUT : +default : + ret = -EINVAL ; +dev_err (dev,"invalid operations.\n" ); +return ret; + } + +/* Reset status */ +fimc_write (0x0 ,EXYNOS_CISTATUS ); + + cfg0 =fimc_read (EXYNOS_CIIMGCPT ); + cfg0 &= ~EXYNOS_CIIMGCPT_IMGCPTEN_SC ; + cfg0 |=EXYNOS_CIIMGCPT_IMGCPTEN_SC ; + +/* Scaler */ + cfg1 =fimc_read (EXYNOS_CISCCTRL ); + cfg1 &= ~EXYNOS_CISCCTRL_SCAN_MASK ; + cfg1 |= (EXYNOS_CISCCTRL_PROGRESSIVE | +EXYNOS_CISCCTRL_SCALERSTART ); + +fimc_write (cfg1,EXYNOS_CISCCTRL ); + +/* Enable image capture*/ + cfg0 |=EXYNOS_CIIMGCPT_IMGCPTEN ; +fimc_write (cfg0,EXYNOS_CIIMGCPT ); + +/* Disable frame end irq */ + cfg0 =fimc_read (EXYNOS_CIGCTRL ); + cfg0 &= ~EXYNOS_CIGCTRL_IRQ_END_DISABLE ; +fimc_write (cfg0,EXYNOS_CIGCTRL ); + + cfg0 =fimc_read (EXYNOS_CIOCTRL ); + cfg0 &= ~EXYNOS_CIOCTRL_WEAVE_MASK ; +fimc_write (cfg0,EXYNOS_CIOCTRL ); + +/* ToDo: m2m start errata - refer fimd */ +if (cmd ==IPP_CMD_M2M ) { + cfg0 =fimc_read (EXYNOS_MSCTRL ); + cfg0 |=EXYNOS_MSCTRL_ENVID ; +fimc_write (cfg0,EXYNOS_MSCTRL ); + + cfg0 =fimc_read (EXYNOS_MSCTRL ); + cfg0 |=EXYNOS_MSCTRL_ENVID ; +fimc_write (cfg0,EXYNOS_MSCTRL ); + } + +return 0 ; +} + +static void fimc_ippdrv_stop (struct device *dev,enum drm_exynos_ipp_cmd cmd) +{ +struct fimc_context *ctx =get_fimc_context (dev); +struct drm_exynos_ipp_set_wb set_wb = {0 ,0 }; +u32 cfg; + +DRM_DEBUG_KMS ("%s:cmd[%d]\n" , __func__, cmd); + +switch (cmd) { +case IPP_CMD_M2M : +/* Source clear */ + cfg =fimc_read (EXYNOS_MSCTRL ); + cfg &= ~EXYNOS_MSCTRL_INPUT_MASK ; + cfg &= ~EXYNOS_MSCTRL_ENVID ; +fimc_write (cfg,EXYNOS_MSCTRL ); +break ; +case IPP_CMD_WB : +exynos_drm_ippnb_send_event (IPP_SET_WRITEBACK , (void *)&set_wb); +break ; +case IPP_CMD_OUTPUT : +default : +dev_err (dev,"invalid operations.\n" ); +break ; + } + +fimc_handle_irq (ctx, false, false, true); + +/* reset sequence */ +fimc_write (0x0 ,EXYNOS_CIFCNTSEQ ); + +/* Scaler disable */ + cfg =fimc_read (EXYNOS_CISCCTRL ); + cfg &= ~EXYNOS_CISCCTRL_SCALERSTART ; +fimc_write (cfg,EXYNOS_CISCCTRL ); + +/* Disable image capture */ + cfg =fimc_read (EXYNOS_CIIMGCPT ); + cfg &= ~(EXYNOS_CIIMGCPT_IMGCPTEN_SC |EXYNOS_CIIMGCPT_IMGCPTEN ); +fimc_write (cfg,EXYNOS_CIIMGCPT ); + +/* Enable frame end irq */ + cfg =fimc_read (EXYNOS_CIGCTRL ); + cfg |=EXYNOS_CIGCTRL_IRQ_END_DISABLE ; +fimc_write (cfg,EXYNOS_CIGCTRL ); +} + +static struct fimc_capability *fimc_get_capability ( +enum exynos_drm_fimc_ver ver) +{ +struct fimc_capability *capa; + +DRM_DEBUG_KMS ("%s:ver[0x%x]\n" , __func__, ver); + +/* ToDo: version check */ +switch (ver) { +case FIMC_EXYNOS_4412 : +case FIMC_EXYNOS_4412_R2 : +default : + capa = fimc51_capa; +break ; + } + +return capa; +} + +static int fimc_get_clk_rate (enum exynos_drm_fimc_ver ver) +{ +int clk_rate; + +DRM_DEBUG_KMS ("%s:ver[0x%x]\n" , __func__, ver); + +switch (ver) { +case FIMC_EXYNOS_4412_R2 : + clk_rate =FIMC_CLK_RATE_R2 ; +break ; +case FIMC_EXYNOS_4412 : +default : + clk_rate =FIMC_CLK_RATE ; +break ; + } + +return clk_rate; +} + +static int __devinit fimc_probe (struct platform_device *pdev) +{ +struct device *dev = &pdev->dev; +struct fimc_context *ctx; +struct clk *parent_clk; +struct resource *res; +struct exynos_drm_ippdrv *ippdrv; +struct exynos_drm_fimc_pdata *pdata; +int ret = -EINVAL ; + + pdata = pdev->dev.platform_data; +if (!pdata) { +dev_err (dev,"no platform data specified.\n" ); +return -EINVAL ; + } + + ctx =kzalloc (sizeof (*ctx),GFP_KERNEL ); +if (!ctx) +return -ENOMEM ; + +/* clock control */ + ctx->sclk_fimc_clk =clk_get (dev,"sclk_fimc" ); +if (IS_ERR (ctx->sclk_fimc_clk)) { +dev_err (dev,"failed to get src fimc clock.\n" ); + ret =PTR_ERR (ctx->sclk_fimc_clk); + goto err_ctx; + } +clk_enable (ctx->sclk_fimc_clk); + + ctx->fimc_clk =clk_get (dev,"fimc" ); +if (IS_ERR (ctx->fimc_clk)) { +dev_err (dev,"failed to get fimc clock.\n" ); + ret =PTR_ERR (ctx->fimc_clk); +clk_put (ctx->sclk_fimc_clk); + goto err_ctx; + } + + ctx->wb_clk =clk_get (dev,"pxl_async0" ); +if (IS_ERR (ctx->wb_clk)) { +dev_err (dev,"failed to get writeback a clock.\n" ); + ret =PTR_ERR (ctx->wb_clk); +clk_put (ctx->sclk_fimc_clk); +clk_put (ctx->fimc_clk); + goto err_ctx; + } + + ctx->wb_b_clk =clk_get (dev,"pxl_async1" ); +if (IS_ERR (ctx->wb_b_clk)) { +dev_err (dev,"failed to get writeback b clock.\n" ); + ret =PTR_ERR (ctx->wb_b_clk); +clk_put (ctx->sclk_fimc_clk); +clk_put (ctx->fimc_clk); +clk_put (ctx->wb_clk); + goto err_ctx; + } + +if (pdata->ver ==FIMC_EXYNOS_4210 ) + parent_clk =clk_get (dev,"mout_mpll" ); +else + parent_clk =clk_get (dev,"mout_mpll_user" ); + +if (IS_ERR (parent_clk)) { +dev_err (dev,"failed to get parent clock.\n" ); + ret =PTR_ERR (parent_clk); +clk_put (ctx->sclk_fimc_clk); +clk_put (ctx->fimc_clk); +clk_put (ctx->wb_clk); +clk_put (ctx->wb_b_clk); + goto err_ctx; + } + +if (clk_set_parent (ctx->sclk_fimc_clk, parent_clk)) { +dev_err (dev,"failed to set parent.\n" ); +clk_put (parent_clk); +clk_put (ctx->sclk_fimc_clk); +clk_put (ctx->fimc_clk); +clk_put (ctx->wb_clk); +clk_put (ctx->wb_b_clk); + goto err_ctx; + } +clk_put (parent_clk); +clk_set_rate (ctx->sclk_fimc_clk,fimc_get_clk_rate (pdata->ver)); +if (pdata->ver ==FIMC_EXYNOS_4210 ) +clk_put (ctx->sclk_fimc_clk); +else +clk_disable (ctx->sclk_fimc_clk); + +/* resource memory */ + res =platform_get_resource (pdev,IORESOURCE_MEM ,0 ); +if (!res) { +dev_err (dev,"failed to find registers.\n" ); + ret = -ENOENT ; + goto err_clk; + } + + ctx->regs_res =request_mem_region (res->start,resource_size (res), +dev_name (dev)); +if (!ctx->regs_res) { +dev_err (dev,"failed to claim register region.\n" ); + ret = -ENOENT ; + goto err_clk; + } + + ctx->regs =ioremap (res->start,resource_size (res)); +if (!ctx->regs) { +dev_err (dev,"failed to map registers.\n" ); + ret = -ENXIO ; + goto err_req_region; + } + +/* resource irq */ + res =platform_get_resource (pdev,IORESOURCE_IRQ ,0 ); +if (!res) { +dev_err (dev,"failed to request irq resource.\n" ); + goto err_get_regs; + } + + ctx->irq = res->start; + ret =request_threaded_irq (ctx->irq,NULL , fimc_irq_handler, +IRQF_ONESHOT ,"drm_fimc" , ctx); +if (ret <0 ) { +dev_err (dev,"failed to request irq.\n" ); + goto err_get_regs; + } + +/* context initailization */ + ctx->ver = pdata->ver; + ctx->id = pdev->id; + ctx->capa =fimc_get_capability (ctx->ver); +if (!ctx->capa) { +dev_err (dev,"failed to get capability.\n" ); + goto err_get_irq; + } + ctx->pol = pdata->pol; + + ippdrv = &ctx->ippdrv; + ippdrv->dev = dev; + ippdrv->ops[EXYNOS_DRM_OPS_SRC ] = &fimc_src_ops; + ippdrv->ops[EXYNOS_DRM_OPS_DST ] = &fimc_dst_ops; + ippdrv->check_property = fimc_ippdrv_check_property; + ippdrv->reset = fimc_ippdrv_reset; + ippdrv->start = fimc_ippdrv_start; + ippdrv->stop = fimc_ippdrv_stop; + ret =fimc_init_prop_list (&ippdrv->prop_list); +if (ret <0 ) { +dev_err (dev,"failed to init property list.\n" ); + goto err_get_irq; + } + +DRM_DEBUG_KMS ("%s:id[%d]ippdrv[0x%x]\n" , __func__, ctx->id, + (int )ippdrv); + +spin_lock_init (&ctx->lock); +platform_set_drvdata (pdev, ctx); + +pm_runtime_set_active (dev); +pm_runtime_enable (dev); + + ret =exynos_drm_ippdrv_register (ippdrv); +if (ret <0 ) { +dev_err (dev,"failed to register drm fimc device.\n" ); + goto err_ippdrv_register; + } + +dev_info (&pdev->dev,"drm fimc registered successfully.\n" ); + +return 0 ; + +err_ippdrv_register: +kfree (ippdrv->prop_list); +pm_runtime_disable (dev); +free_irq (ctx->irq, ctx); +err_get_irq: +free_irq (ctx->irq, ctx); +err_get_regs: +iounmap (ctx->regs); +err_req_region: +release_resource (ctx->regs_res); +kfree (ctx->regs_res); +err_clk: +clk_put (ctx->sclk_fimc_clk); +clk_put (ctx->fimc_clk); +clk_put (ctx->wb_clk); +clk_put (ctx->wb_b_clk); +err_ctx: +kfree (ctx); +return ret; +} + +static int __devexit fimc_remove(struct platform_device *pdev) +{ +struct device *dev = &pdev->dev; +struct fimc_context *ctx =get_fimc_context (dev); +struct exynos_drm_ippdrv *ippdrv = &ctx->ippdrv; + +kfree (ippdrv->prop_list); +exynos_drm_ippdrv_unregister (ippdrv); + +pm_runtime_set_suspended (dev); +pm_runtime_disable (dev); + +free_irq (ctx->irq, ctx); +iounmap (ctx->regs); +release_resource (ctx->regs_res); +kfree (ctx->regs_res); + +clk_put (ctx->sclk_fimc_clk); +clk_put (ctx->fimc_clk); +clk_put (ctx->wb_clk); +clk_put (ctx->wb_b_clk); + +kfree (ctx); + +return 0 ; +} + +#ifdef CONFIG_PM_SLEEP +static int fimc_suspend (struct device *dev) +{ +struct fimc_context *ctx =get_fimc_context (dev); + +DRM_DEBUG_KMS ("%s:id[%d]\n" , __func__, ctx->id); +if (pm_runtime_suspended (dev)) +return 0 ; +/* ToDo */ +return fimc_power_on (ctx, false); +} + +static int fimc_resume (struct device *dev) +{ +struct fimc_context *ctx =get_fimc_context (dev); + +DRM_DEBUG_KMS ("%s:id[%d]\n" , __func__, ctx->id); +if (!pm_runtime_suspended (dev)) +return fimc_power_on (ctx, true); +/* ToDo */ +return 0 ; +} +#endif + +#ifdef CONFIG_PM_RUNTIME +static int fimc_runtime_suspend (struct device *dev) +{ +struct fimc_context *ctx =get_fimc_context (dev); + +DRM_DEBUG_KMS ("%s:id[%d]\n" , __func__, ctx->id); +/* ToDo */ +return fimc_power_on (ctx, false); +} + +static int fimc_runtime_resume (struct device *dev) +{ +struct fimc_context *ctx =get_fimc_context (dev); + +DRM_DEBUG_KMS ("%s:id[%d]\n" , __func__, ctx->id); +/* ToDo */ +return fimc_power_on (ctx, true); +} +#endif + +static const struct dev_pm_ops fimc_pm_ops = { + SET_SYSTEM_SLEEP_PM_OPS(fimc_suspend, fimc_resume) +SET_RUNTIME_PM_OPS (fimc_runtime_suspend, fimc_runtime_resume,NULL ) +}; + +/* ToDo: need to check use case platform_device_id */ +struct platform_driver fimc_driver = { + .probe = fimc_probe, + .remove =__devexit_p (fimc_remove), + .driver = { + .name ="exynos-drm-fimc" , + .owner =THIS_MODULE , + .pm = &fimc_pm_ops, + }, +}; +<snip>
Quoted 3 lines
Best Regards,
- Seung-Woo Kim
BR
Eunchul Kim.
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
RFC 3/4 drm/exynos: add rotator ipp driver
In reply to Eunchul KimRotator supports rotation/crop/flip and input/output DMA operations Rotator ipp driver supports 90,180,270 degree rotaion and vertical, horizontal flip. and has some limitations(source and destination format have to be same, no scaler)
--- drivers/gpu/drm/exynos/Kconfig | 6 + drivers/gpu/drm/exynos/Makefile | 1 + drivers/gpu/drm/exynos/exynos_drm_drv.c | 15 + drivers/gpu/drm/exynos/exynos_drm_drv.h | 1 + drivers/gpu/drm/exynos/exynos_drm_rotator.c | 801 +++++++++++++++++++++++++++ drivers/gpu/drm/exynos/exynos_drm_rotator.h | 13 + drivers/gpu/drm/exynos/regs-rotator.h | 73 +++ 7 files changed, 910 insertions(+), 0 deletions(-) create mode 100644 drivers/gpu/drm/exynos/exynos_drm_rotator.c create mode 100644 drivers/gpu/drm/exynos/exynos_drm_rotator.h create mode 100644 drivers/gpu/drm/exynos/regs-rotator.h
drivers/gpu/drm/exynos/Kconfig +6 -0
@@ -51,3 +51,9 @@ config DRM_EXYNOS_FIMC depends on DRM_EXYNOS_IPP help Choose this option if you want to use Exynos FIMC for DRM. + +config DRM_EXYNOS_ROTATOR + bool "Exynos DRM Rotator" + depends on DRM_EXYNOS_IPP + help + Choose this option if you want to use Exynos Rotator for DRM.
drivers/gpu/drm/exynos/Makefile +1 -0
@@ -17,5 +17,6 @@ exynosdrm-$(CONFIG_DRM_EXYNOS_VIDI) += exynos_drm_vidi.o exynosdrm-$(CONFIG_DRM_EXYNOS_G2D) += exynos_drm_g2d.o exynosdrm-$(CONFIG_DRM_EXYNOS_IPP) += exynos_drm_ipp.o exynosdrm-$(CONFIG_DRM_EXYNOS_FIMC) += exynos_drm_fimc.o +exynosdrm-$(CONFIG_DRM_EXYNOS_ROTATOR) += exynos_drm_rotator.o obj-$(CONFIG_DRM_EXYNOS) += exynosdrm.o
drivers/gpu/drm/exynos/exynos_drm_drv.c +15 -0
@@ -361,6 +361,12 @@ static int __init exynos_drm_init(void) goto out_fimc;#endif +#ifdef CONFIG_DRM_EXYNOS_ROTATOR + ret =platform_driver_register (&rotator_driver); +if (ret <0 ) + goto out_rotator; +#endif +#ifdef CONFIG_DRM_EXYNOS_IPP ret =platform_driver_register (&ipp_driver);if (ret <0 )
@@ -389,6 +395,11 @@ out_drm: out_ipp:#endif +#ifdef CONFIG_DRM_EXYNOS_ROTATOR +platform_driver_unregister (&rotator_driver); +out_rotator: +#endif +#ifdef CONFIG_DRM_EXYNOS_FIMC platform_driver_unregister (&fimc_driver); out_fimc:
@@ -434,6 +445,10 @@ static void __exit exynos_drm_exit(void)platform_driver_unregister (&ipp_driver);#endif +#ifdef CONFIG_DRM_EXYNOS_ROTATOR +platform_driver_unregister (&rotator_driver); +#endif +#ifdef CONFIG_DRM_EXYNOS_FIMC platform_driver_unregister (&fimc_driver);#endif
drivers/gpu/drm/exynos/exynos_drm_drv.h +1 -0
@@ -342,5 +342,6 @@ extern struct platform_driver exynos_drm_common_hdmi_driver;extern struct platform_driver vidi_driver;extern struct platform_driver g2d_driver;extern struct platform_driver fimc_driver; +extern struct platform_driver rotator_driver;extern struct platform_driver ipp_driver;#endif
drivers/gpu/drm/exynos/exynos_drm_rotator.c new file +801 -0
801 lines not on this page · raw message
drivers/gpu/drm/exynos/exynos_drm_rotator.h new file +13 -0
@@ -0,0 +1,13 @@ +/* +* Copyright (C) 2012 Samsung Electronics Co.Ltd +* Authors: YoungJun Cho <[email protected]> +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License version 2 as +* published by the Free Software Foundationr +*/ + +#ifndef _EXYNOS_DRM_ROTATOR_H_ +#define _EXYNOS_DRM_ROTATOR_H_ + +#endif
drivers/gpu/drm/exynos/regs-rotator.h new file +73 -0
73 lines not on this page · raw message
Signature · 1 line
1.7.0.4
RFC 4/4 drm/exynos: add gsc ipp driver
In reply to Eunchul KimGSC is stand for General SCaler and supports supports image scaler/rotator/crop/flip/csc and input/output DMA operations. input DMA reads image data from the memory.
output DMA writes image data to memory.
GSC supports image rotation and imag effect functions. also supports writeback and display output operations.
--- drivers/gpu/drm/exynos/Kconfig | 6 + drivers/gpu/drm/exynos/Makefile | 1 + drivers/gpu/drm/exynos/exynos_drm_drv.c | 15 + drivers/gpu/drm/exynos/exynos_drm_drv.h | 1 + drivers/gpu/drm/exynos/exynos_drm_gsc.c | 1476 +++++++++++++++++++++++++++++++ drivers/gpu/drm/exynos/exynos_drm_gsc.h | 35 + drivers/gpu/drm/exynos/regs-gsc.h | 295 ++++++ 7 files changed, 1829 insertions(+), 0 deletions(-) create mode 100644 drivers/gpu/drm/exynos/exynos_drm_gsc.c create mode 100644 drivers/gpu/drm/exynos/exynos_drm_gsc.h create mode 100644 drivers/gpu/drm/exynos/regs-gsc.h
drivers/gpu/drm/exynos/Kconfig +6 -0
@@ -57,3 +57,9 @@ config DRM_EXYNOS_ROTATOR depends on DRM_EXYNOS_IPP help Choose this option if you want to use Exynos Rotator for DRM. + +config DRM_EXYNOS_GSC + bool "Exynos DRM GSC" + depends on DRM_EXYNOS_IPP && ARCH_EXYNOS5 + help + Choose this option if you want to use Exynos GSC for DRM.
drivers/gpu/drm/exynos/Makefile +1 -0
@@ -18,5 +18,6 @@ exynosdrm-$(CONFIG_DRM_EXYNOS_G2D) += exynos_drm_g2d.o exynosdrm-$(CONFIG_DRM_EXYNOS_IPP) += exynos_drm_ipp.o exynosdrm-$(CONFIG_DRM_EXYNOS_FIMC) += exynos_drm_fimc.o exynosdrm-$(CONFIG_DRM_EXYNOS_ROTATOR) += exynos_drm_rotator.o +exynosdrm-$(CONFIG_DRM_EXYNOS_GSC) += exynos_drm_gsc.o obj-$(CONFIG_DRM_EXYNOS) += exynosdrm.o
drivers/gpu/drm/exynos/exynos_drm_drv.c +15 -0
@@ -367,6 +367,12 @@ static int __init exynos_drm_init(void) goto out_rotator;#endif +#ifdef CONFIG_DRM_EXYNOS_GSC + ret =platform_driver_register (&gsc_driver); +if (ret <0 ) + goto out_gsc; +#endif +#ifdef CONFIG_DRM_EXYNOS_IPP ret =platform_driver_register (&ipp_driver);if (ret <0 )
@@ -395,6 +401,11 @@ out_drm: out_ipp:#endif +#ifdef CONFIG_DRM_EXYNOS_GSC +platform_driver_unregister (&gsc_driver); +out_gsc: +#endif +#ifdef CONFIG_DRM_EXYNOS_ROTATOR platform_driver_unregister (&rotator_driver); out_rotator:
@@ -445,6 +456,10 @@ static void __exit exynos_drm_exit(void)platform_driver_unregister (&ipp_driver);#endif +#ifdef CONFIG_DRM_EXYNOS_GSC +platform_driver_unregister (&gsc_driver); +#endif +#ifdef CONFIG_DRM_EXYNOS_ROTATOR platform_driver_unregister (&rotator_driver);#endif
drivers/gpu/drm/exynos/exynos_drm_drv.h +1 -0
@@ -343,5 +343,6 @@ extern struct platform_driver vidi_driver;extern struct platform_driver g2d_driver;extern struct platform_driver fimc_driver;extern struct platform_driver rotator_driver; +extern struct platform_driver gsc_driver;extern struct platform_driver ipp_driver;#endif
drivers/gpu/drm/exynos/exynos_drm_gsc.c new file +1476 -0
1,476 lines not on this page · raw message
drivers/gpu/drm/exynos/exynos_drm_gsc.h new file +35 -0
@@ -0,0 +1,35 @@ +/* +* Copyright (c) 2012 Samsung Electronics Co., Ltd. +* +* Authors: +* Eunchul Kim <[email protected]> +* Jinyoung Jeon <[email protected]> +* Sangmin Lee <[email protected]> +* +* Permission is hereby granted, free of charge, to any person obtaining a +* copy of this software and associated documentation files (the "Software"), +* to deal in the Software without restriction, including without limitation +* the rights to use, copy, modify, merge, publish, distribute, sublicense, +* and/or sell copies of the Software, and to permit persons to whom the +* Software is furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice (including the next +* paragraph) shall be included in all copies or substantial portions of the +* Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +* VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR +* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +* OTHER DEALINGS IN THE SOFTWARE. +*/ + +#ifndef _EXYNOS_DRM_GSC_H_ +#define _EXYNOS_DRM_GSC_H_ + +/* ToDo */ + +#endif /* _EXYNOS_DRM_GSC_H_ */ +
drivers/gpu/drm/exynos/regs-gsc.h new file +295 -0
295 lines not on this page · raw message
Signature · 1 line
1.7.0.4