camera: add dvp camera [1/1]

PD#OTT-1204

Problem:
don't support dvp camera

Solution:
add dvp camera gc2145 camera driver

Verify:
test pass on U200

Change-Id: I0451160d013cd15b32a11469926fe8be4c35c466
Signed-off-by: Guosong Zhou <guosong.zhou@amlogic.com>

Conflicts:
	MAINTAINERS
	arch/arm/boot/dts/amlogic/g12a_s905d2_u200.dts
	drivers/amlogic/media/camera/common/vm.c
	drivers/amlogic/media/camera/common/vm.h
	drivers/amlogic/media/camera/gc2145.c
This commit is contained in:
Guosong Zhou
2018-12-28 21:17:04 -05:00
committed by Dongjin Kim
parent de6ccab8c8
commit bbbf5c116e
3 changed files with 36 additions and 71 deletions

View File

@@ -29,7 +29,6 @@
#include <linux/amlogic/media/vfm/vframe.h>
#include <linux/amlogic/media/vfm/vframe_provider.h>
#include <linux/amlogic/media/vfm/vframe_receiver.h>
#include <linux/amlogic/media/vfm/vfm_ext.h>
#include <linux/amlogic/media/ge2d/ge2d_cmd.h>
#include <linux/amlogic/media/ge2d/ge2d.h>
#include <linux/kthread.h>
@@ -1635,9 +1634,22 @@ static int simulate_task(void *data)
***********************************************
*/
int alloc_vm_canvas(struct vm_device_s *vdevp)
int vm_buffer_init(struct vm_device_s *vdevp)
{
int j;
int i, j;
u32 canvas_width, canvas_height;
u32 decbuf_size;
resource_size_t buf_start;
unsigned int buf_size;
int buf_num = 0;
int local_pool_size = 0;
init_completion(&vdevp->vb_start_sema);
init_completion(&vdevp->vb_done_sema);
buf_start = vdevp->buffer_start;
buf_size = vdevp->buffer_size;
if (vdevp->index == 0) {
for (j = 0; j < MAX_CANVAS_INDEX; j++) {
memset(&(vdevp->vm_canvas[j]), -1, sizeof(int));
@@ -1660,25 +1672,6 @@ int alloc_vm_canvas(struct vm_device_s *vdevp)
}
}
return 0;
}
int vm_buffer_init(struct vm_device_s *vdevp)
{
int i;
u32 canvas_width, canvas_height;
u32 decbuf_size;
resource_size_t buf_start;
unsigned int buf_size;
int buf_num = 0;
int local_pool_size = 0;
init_completion(&vdevp->vb_start_sema);
init_completion(&vdevp->vb_done_sema);
buf_start = vdevp->buffer_start;
buf_size = vdevp->buffer_size;
if (!buf_start || !buf_size)
goto exit;
@@ -2016,20 +2009,6 @@ int init_vm_device(struct vm_device_s *vdevp, struct platform_device *pdev)
vdevp->task_running = 0;
memset(&vdevp->output_para, 0, sizeof(struct vm_output_para));
sprintf(vdevp->name, "%s%d", RECEIVER_NAME, vdevp->index);
sprintf(vdevp->vf_provider_name, "%s%d", "vdin", vdevp->index);
snprintf(vdevp->vfm_map_chain, VM_MAP_NAME_SIZE,
"%s %s", vdevp->vf_provider_name,
vdevp->name);
snprintf(vdevp->vfm_map_id, VM_MAP_NAME_SIZE,
"vm-map-%d", vdevp->index);
if (vfm_map_add(vdevp->vfm_map_id,
vdevp->vfm_map_chain) < 0) {
pr_err("vm pipeline map creation failed %s.\n",
vdevp->vfm_map_id);
goto fail_create_dev_file;
}
vf_receiver_init(&vdevp->vm_vf_recv, vdevp->name,
&vm_vf_receiver, vdevp);
@@ -2204,12 +2183,7 @@ static int vm_driver_probe(struct platform_device *pdev)
}
vm_device[vdevp->index] = vdevp;
vdevp->pdev = pdev;
platform_set_drvdata(pdev, vdevp);
ret = alloc_vm_canvas(vdevp);
if (ret != 0) {
pr_err("alloc vm canvas failed\n");
return ret;
}
vm_buffer_init(vdevp);
ret = init_vm_device(vdevp, pdev);
if (ret != 0)
@@ -2227,23 +2201,22 @@ static int vm_driver_probe(struct platform_device *pdev)
static int vm_drv_remove(struct platform_device *plat_dev)
{
int i;
struct vm_device_s *vdevp;
vdevp = platform_get_drvdata(plat_dev);
for (i = 0; i < MAX_CANVAS_INDEX; i++) {
if ((vdevp != NULL) &&
(vdevp->vm_canvas[i] >= 0)) {
if ((vm_device[0] != NULL) &&
(vm_device[0]->vm_canvas[i] >= 0)) {
canvas_pool_map_free_canvas(
vdevp->vm_canvas[i]);
memset(&(vdevp->vm_canvas[i]),
vm_device[0]->vm_canvas[i]);
memset(&(vm_device[0]->vm_canvas[i]),
-1, sizeof(int));
}
if ((vm_device[1] != NULL) &&
(vm_device[1]->vm_canvas[i] >= 0)) {
canvas_pool_map_free_canvas(
vm_device[1]->vm_canvas[i]);
memset(&(vm_device[1]->vm_canvas[i]),
-1, sizeof(int));
}
}
if (vdevp->vfm_map_id[0]) {
vfm_map_remove(vdevp->vfm_map_id);
vdevp->vfm_map_id[0] = 0;
}
uninit_vm_device(plat_dev);

View File

@@ -47,9 +47,6 @@
#define VM_IOC_CONFIG_FRAME _IOW(VM_IOC_MAGIC, 0X02, unsigned int)
#define MAX_CANVAS_INDEX 12
#define VM_MAP_NAME_SIZE 100
#define VM_PROVIDER_NAME_SIZE 10
struct vm_device_s {
unsigned int index;
char name[20];
@@ -76,9 +73,6 @@ struct vm_device_s {
struct vm_output_para output_para;
struct completion vb_start_sema;
struct completion vb_done_sema;
char vf_provider_name[VM_PROVIDER_NAME_SIZE];
char vfm_map_id[VM_MAP_NAME_SIZE];
char vfm_map_chain[VM_MAP_NAME_SIZE];
int vm_canvas[MAX_CANVAS_INDEX];
};
@@ -95,7 +89,6 @@ struct display_frame_s {
int start_vm_task(struct vm_device_s *vdevp);
int start_simulate_task(void);
int alloc_vm_canvas(struct vm_device_s *vdevp);
extern int get_vm_status(void);
extern void set_vm_status(int flag);

View File

@@ -503,8 +503,7 @@ static struct v4l2_frmsize_discrete
static struct v4l2_frmsize_discrete gc2145_pic_resolution[] = {
{1600, 1200},
{800, 600},
{640, 480}
{800, 600}
};
#ifndef GC2145_MIRROR
@@ -1819,23 +1818,23 @@ void GC2145_set_resolution(struct gc2145_device *dev, int height, int width)
if ((width * height < 1600 * 1200)) {
while (1) {
buf[0] = gc2145_uxga[i].addr;
buf[1] = gc2145_uxga[i].val;
if (gc2145_uxga[i].val == 0xff &&
gc2145_uxga[i].addr == 0xff) {
pr_info("success in gc2145_uxga.\n");
buf[0] = gc2145_svga[i].addr;
buf[1] = gc2145_svga[i].val;
if (gc2145_svga[i].val == 0xff &&
gc2145_svga[i].addr == 0xff) {
pr_info("success in gc2145_svga.\n");
break;
}
if ((i2c_put_byte_add8(client, buf, 2)) < 0) {
pr_err("fail in gc2145_uxga.\n");
pr_err("fail in gc2145_svga.\n");
return;
}
i++;
}
gc2145_frmintervals_active.numerator = 1;
gc2145_frmintervals_active.denominator = 15;
GC2145_h_active = 1600;
GC2145_v_active = 1200;
GC2145_h_active = 800;
GC2145_v_active = 600;
mdelay(80);
} else if (width * height >= 1200 * 1600) {
buf[0] = 0xfe;