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: I5927d49a93952587af7bb460a5c405293d692153
Signed-off-by: Guosong Zhou <guosong.zhou@amlogic.com>
Signed-off-by: Luan Yuan <luan.yuan@amlogic.com>
This commit is contained in:
Guosong Zhou
2019-01-02 06:00:30 -05:00
committed by Dongjin Kim
parent 15b29c9e38
commit 340349c245
25 changed files with 11562 additions and 18 deletions

View File

@@ -14732,6 +14732,19 @@ AMLOGIC BACKLIGHT LDIM DRIVER
M: Evoke Zhang <evoke.zhang@amlogic.com>
F: drivers/amlogic/media/vout/backlight/aml_ldim/ldim_spi.c
AMLOGIC CAMERA DRIVER
M: Guosong Zhou <guosong.zhou@amlogic.com>
F: arch/arm64/boot/dts/amlogic/g12a_s905d2_u200.dts
F: arch/arm/boot/dts/amlogic/g12a_s905d2_u200.dts
F: arch/arm64/configs/meson64_defconfig
F: arch/arm/configs/meson64_a32_defconfig
F: drivers/amlogic/media/Kconfig
F: drivers/amlogic/media/Makefile
F: drivers/amlogic/media/camera/*
F: drivers/amlogic/media/common/canvas/canvas_mgr.c
F: drivers/amlogic/media/common/vfm/vfm.c
F: include/linux/amlogic/media/camera/*
HARDKERNEL S922D odroidn2
M: Joy Cho <joy.cho@hardkernel.com>
F: arch/arm64/configs/odroidn2_defconfig

View File

@@ -151,6 +151,12 @@
size = <0x04000000>;
alignment = <0x400000>;
};
vm0_cma_reserved:linux,vm0_cma {
compatible = "shared-dma-pool";
reusable;
size = <0x0 0x2000000>;
alignment = <0x0 0x400000>;
};
};
gpioleds {
@@ -284,6 +290,54 @@
dev_name = "ionvideo";
status = "okay";
};
vm0 {
compatible = "amlogic, vm";
memory-region = <&vm0_cma_reserved>;
dev_name = "vm0";
status = "disabled";
vm_id = <0>;
};
amvdec_656in {
/*bt656 gpio conflict with i2c0*/
compatible = "amlogic, amvdec_656in";
dev_name = "amvdec_656in";
status = "disabled";
reg = <0x0 0xffe02000 0x0 0x7c>;
clocks = <&clkc CLKID_BT656_COMP>,
<&clkc CLKID_BT656>;
clock-names = "cts_bt656_clk1",
"clk_gate_bt656";
/* bt656in1, bt656in2 */
bt656in1 {
bt656_id = <1>;
status = "disabled";
};
};
aml_cams {
compatible = "amlogic, cams_prober";
status = "disabled";
pinctrl-names="default";
pinctrl-0=<&cam_dvp_pins &gen_clk_ee_z>;
clocks = <&clkc CLKID_GEN_CLK>;
clock-names = "g12a_24m";
cam_0{
cam_name = "gc2145";
front_back = <0>;
/*u200 i2c2 gpio conflict with ethmac*/
camera-i2c-bus = <&i2c2>;
gpio_pwdn-gpios = <&gpio GPIOZ_2 GPIO_ACTIVE_HIGH>;
gpio_rst-gpios = <&gpio GPIOZ_12 GPIO_ACTIVE_HIGH>;
mirror_flip = <1>;
vertical_flip = <1>;
spread_spectrum = <0>;
bt_path = "gpio";
bt_path_count = <1>;
vdin_path = <0>;
status = "okay";
};
};
gpio_keypad{
compatible = "amlogic, gpio_keypad";
@@ -789,6 +843,13 @@
};
};
&i2c2 {
status = "disabled";
pinctrl-names="default";
pinctrl-0=<&i2c2_master_pins2>;
clock-frequency = <100000>;
};
&i2c3 {
status = "okay";
pinctrl-names="default";
@@ -1124,6 +1185,32 @@
};
};
clk12_24_z_pins:clk12_24_z_pins {
mux {
groups = "clk12_24_z";
function = "clk12_24_ee";
drive-strength = <3>;
};
};
gen_clk_ee_z: gen_clk_ee_z {
mux {
groups="gen_clk_ee_z";
function="gen_clk_ee";
drive-strength = <3>;
};
};
cam_dvp_pins:cam_dvp_pins {
mux {
groups = "bt656_a_vs", "bt656_a_hs", "bt656_a_clk",
"bt656_a_din0", "bt656_a_din1", "bt656_a_din2",
"bt656_a_din3", "bt656_a_din4", "bt656_a_din5",
"bt656_a_din6", "bt656_a_din7";
function = "bt656";
};
};
}; /* end of pinctrl_periphs */
&pinctrl_aobus {

View File

@@ -325,6 +325,9 @@ CONFIG_AMLOGIC_MEDIA_ENHANCEMENT=y
CONFIG_AMLOGIC_MEDIA_ENHANCEMENT_VECM=y
CONFIG_AMLOGIC_MEDIA_ENHANCEMENT_DOLBYVISION=y
CONFIG_AMLOGIC_MEDIA_GDC=y
CONFIG_AMLOGIC_VIDEO_CAPTURE=y
CONFIG_AMLOGIC_VM_DISABLE_VIDEOLAYER=y
CONFIG_AMLOGIC_VIDEO_CAPTURE_GC2145=y
CONFIG_AMLOGIC_DTV_DEMOD=y
CONFIG_AMLOGIC_MMC=y
CONFIG_AMLOGIC_NAND=y

View File

@@ -149,6 +149,12 @@
size = <0x0 0x04000000>;
alignment = <0x0 0x400000>;
};
vm0_cma_reserved:linux,vm0_cma {
compatible = "shared-dma-pool";
reusable;
size = <0x0 0x2000000>;
alignment = <0x0 0x400000>;
};
};
gpioleds {
@@ -282,6 +288,54 @@
dev_name = "ionvideo";
status = "okay";
};
vm0 {
compatible = "amlogic, vm";
memory-region = <&vm0_cma_reserved>;
dev_name = "vm0";
status = "disabled";
vm_id = <0>;
};
amvdec_656in {
/*bt656 gpio conflict with i2c0*/
compatible = "amlogic, amvdec_656in";
dev_name = "amvdec_656in";
status = "disabled";
reg = <0x0 0xffe02000 0x0 0x7c>;
clocks = <&clkc CLKID_BT656_COMP>,
<&clkc CLKID_BT656>;
clock-names = "cts_bt656_clk1",
"clk_gate_bt656";
/* bt656in1, bt656in2 */
bt656in1 {
bt656_id = <1>;
status = "disabled";
};
};
aml_cams {
compatible = "amlogic, cams_prober";
status = "disabled";
pinctrl-names="default";
pinctrl-0=<&cam_dvp_pins &gen_clk_ee_z>;
clocks = <&clkc CLKID_GEN_CLK>;
clock-names = "g12a_24m";
cam_0{
cam_name = "gc2145";
front_back = <0>;
/*u200 i2c2 gpio conflict with ethmac*/
camera-i2c-bus = <&i2c2>;
gpio_pwdn-gpios = <&gpio GPIOZ_2 GPIO_ACTIVE_HIGH>;
gpio_rst-gpios = <&gpio GPIOZ_12 GPIO_ACTIVE_HIGH>;
mirror_flip = <1>;
vertical_flip = <1>;
spread_spectrum = <0>;
bt_path = "gpio";
bt_path_count = <1>;
vdin_path = <0>;
status = "okay";
};
};
gpio_keypad{
compatible = "amlogic, gpio_keypad";
@@ -787,6 +841,13 @@
};
};
&i2c2 {
status = "disabled";
pinctrl-names="default";
pinctrl-0=<&i2c2_master_pins2>;
clock-frequency = <100000>;
};
&i2c3 {
status = "okay";
pinctrl-names="default";
@@ -1122,6 +1183,32 @@
};
};
clk12_24_z_pins:clk12_24_z_pins {
mux {
groups = "clk12_24_z";
function = "clk12_24_ee";
drive-strength = <3>;
};
};
gen_clk_ee_z: gen_clk_ee_z {
mux {
groups="gen_clk_ee_z";
function="gen_clk_ee";
drive-strength = <3>;
};
};
cam_dvp_pins:cam_dvp_pins {
mux {
groups = "bt656_a_vs", "bt656_a_hs", "bt656_a_clk",
"bt656_a_din0", "bt656_a_din1", "bt656_a_din2",
"bt656_a_din3", "bt656_a_din4", "bt656_a_din5",
"bt656_a_din6", "bt656_a_din7";
function = "bt656";
};
};
}; /* end of pinctrl_periphs */
&pinctrl_aobus {

View File

@@ -321,6 +321,9 @@ CONFIG_AMLOGIC_MEDIA_ENHANCEMENT=y
CONFIG_AMLOGIC_MEDIA_ENHANCEMENT_VECM=y
CONFIG_AMLOGIC_MEDIA_ENHANCEMENT_DOLBYVISION=y
CONFIG_AMLOGIC_MEDIA_GDC=y
CONFIG_AMLOGIC_VIDEO_CAPTURE=y
CONFIG_AMLOGIC_VM_DISABLE_VIDEOLAYER=y
CONFIG_AMLOGIC_VIDEO_CAPTURE_GC2145=y
CONFIG_AMLOGIC_DTV_DEMOD=y
CONFIG_AMLOGIC_MMC=y
CONFIG_AMLOGIC_NAND=y

View File

@@ -94,6 +94,7 @@ source "drivers/amlogic/media/video_processor/Kconfig"
source "drivers/amlogic/media/enhancement/Kconfig"
source "drivers/amlogic/media/gdc/Kconfig"
source "drivers/amlogic/media/algorithm/Kconfig"
source "drivers/amlogic/media/camera/Kconfig"
endif
source "drivers/amlogic/media/dtv_demod/Kconfig"
endmenu

View File

@@ -12,3 +12,4 @@ obj-$(CONFIG_AMLOGIC_DTV_DEMOD) += dtv_demod/
obj-$(CONFIG_AMLOGIC_MEDIA_GDC) += gdc/
obj-$(CONFIG_AMLOGIC_MEDIA_ALGORITHM) += algorithm/
obj-$(CONFIG_AMLOGIC_VIDEO_CAPTURE) += camera/

View File

@@ -0,0 +1,559 @@
menu "Amlogic Camera Support"
config AMLOGIC_VIDEO_CAPTURE
tristate "Amlogic Platform Capture Driver"
depends on !SPARC32 && !SPARC64 &&!AMLOGIC_CAMERA_ENABLE
select VIDEOBUF_VMALLOC
depends on MEDIA_SUPPORT
select VIDEO_DEV
select VIDEO_V4L2
default n
---help---
Amlogic capture driver interface in v4l style.
it can not work well together with
AMLOGIC_CAMERA_ENABLE
Say Y here if you want this driver.
config AMLOGIC_CAPTURE_FRAME_ROTATE
bool "Enable function to support frame rotation"
depends on AMLOGIC_VIDEO_CAPTURE
default n
---help---
It will support frame rotation when enable this config
It will support frame rotation when enable this config
It will support frame rotation when enable this config
It will support frame rotation when enable this config
config AMLOGIC_VM_DISABLE_VIDEOLAYER
bool "Force disable Videolayer when use vm"
depends on AMLOGIC_VIDEO_CAPTURE
default n
---help---
It will disable amvideo provider when enable this config
It will disable amvideo provider when enable this config
It will disable amvideo provider when enable this config
It will disable amvideo provider when enable this config
config AMLOGIC_VIDEO_CAPTURE_PROBE
bool "Force check whether camera devices exist"
depends on AMLOGIC_VIDEO_CAPTURE
default n
---help---
Probe whether the camera devices exist by trying to read its
i2c port. It may cost some time, say Y here if you want it.
Probe whether the camera devices exist by trying to read its
i2c port. It may cost some time, say Y here if you want it.
config AMLCAP_LOG_TIME_USEFORFRAMES
bool "Print Out The Time(ms) For Process A Frame"
depends on AMLOGIC_VIDEO_CAPTURE
default n
---help---
Print out the time used for process a frame, only for developers.
Print out the time used for process a frame, only for developers.
Print out the time used for process a frame, only for developers.
Print out the time used for process a frame, only for developers.
config AMLOGIC_VIDEO_CAPTURE_GT2005
tristate "Amlogic Platform Capture Driver for GT2005"
depends on AMLOGIC_VIDEO_CAPTURE
select VIDEOBUF_VMALLOC
select AMLOGIC_VIDEOIN_MANAGER
select TVIN
select TVIN_BT656
select TVIN_VDIN
default n
---help---
Amlogic capture driver.
Say Y here if you want this driver.
Amlogic capture driver.
Say Y here if you want this driver.
config AMLOGIC_VIDEO_CAPTURE_GC0307
tristate "Amlogic Platform Capture Driver for GC0307"
depends on AMLOGIC_VIDEO_CAPTURE
select VIDEOBUF_VMALLOC
select AMLOGIC_VIDEOIN_MANAGER
select TVIN
select TVIN_BT656
select TVIN_VDIN
default n
---help---
Amlogic capture driver.
Say Y here if you want this driver.
Amlogic capture driver.
Say Y here if you want this driver.
config AMLOGIC_VIDEO_CAPTURE_GC0308
tristate "Amlogic Platform Capture Driver for GC0308"
depends on AMLOGIC_VIDEO_CAPTURE
select VIDEOBUF_VMALLOC
select AMLOGIC_VIDEOIN_MANAGER
select TVIN
select TVIN_BT656
select TVIN_VDIN
default n
---help---
Amlogic capture driver.
Say Y here if you want this driver.
Amlogic capture driver.
Say Y here if you want this driver.
config AMLOGIC_VIDEO_CAPTURE_GC0328
tristate "Amlogic Platform Capture Driver for GC0328"
depends on AMLOGIC_VIDEO_CAPTURE
select VIDEOBUF_VMALLOC
select AMLOGIC_VIDEOIN_MANAGER
select TVIN_BT656IN
select TVIN_VDIN
default n
---help---
Amlogic capture driver.
Say Y here if you want this driver.
Amlogic capture driver.
Say Y here if you want this driver.
config AMLOGIC_VIDEO_CAPTURE_GC0329
tristate "Amlogic Platform Capture Driver for GC0329"
depends on AMLOGIC_VIDEO_CAPTURE
select VIDEOBUF_VMALLOC
select AMLOGIC_VIDEOIN_MANAGER
select TVIN
select TVIN_BT656
select TVIN_VDIN
default n
---help---
Amlogic capture driver.
Say Y here if you want this driver.
Amlogic capture driver.
Say Y here if you want this driver.
config AMLOGIC_VIDEO_CAPTURE_GC2015
tristate "Amlogic Platform Capture Driver for GC2015"
depends on AMLOGIC_VIDEO_CAPTURE
select VIDEOBUF_VMALLOC
select AMLOGIC_VIDEOIN_MANAGER
select TVIN
select TVIN_BT656
select TVIN_VDIN
default n
---help---
Amlogic capture driver.
Say Y here if you want this driver.
Amlogic capture driver.
Say Y here if you want this driver.
config AMLOGIC_VIDEO_CAPTURE_GC2035
tristate "Amlogic Platform Capture Driver for GC2035"
depends on AMLOGIC_VIDEO_CAPTURE
select VIDEOBUF_VMALLOC
select TVIN
select TVIN_BT656
select TVIN_VDIN
default n
---help---
Amlogic capture driver.
Say Y here if you want this driver.
Amlogic capture driver.
Say Y here if you want this driver.
config AMLOGIC_VIDEO_CAPTURE_GC2155
tristate "Amlogic Platform Capture Driver for GC2155"
depends on AMLOGIC_VIDEO_CAPTURE
select VIDEOBUF_VMALLOC
select TVIN
select TVIN_BT656
select TVIN_VDIN
default n
---help---
Amlogic capture driver.
Say Y here if you want this driver.
Amlogic capture driver.
Say Y here if you want this driver.
config AMLOGIC_VIDEO_CAPTURE_GC2145
tristate "Amlogic Platform Capture Driver for GC2145"
depends on AMLOGIC_VIDEO_CAPTURE
select VIDEOBUF_VMALLOC
select AMLOGIC_VIDEOIN_MANAGER
select TVIN
select TVIN_BT656
select TVIN_VDIN
default n
---help---
Amlogic capture driver.
Say Y here if you want this driver.
Amlogic capture driver.
Say Y here if you want this driver.
config AMLOGIC_VIDEO_CAPTURE_OV5640
tristate "Amlogic Platform Capture Driver for OV5640"
depends on AMLOGIC_VIDEO_CAPTURE
select VIDEOBUF_VMALLOC
select AMLOGIC_VIDEOIN_MANAGER
select TVIN
select TVIN_BT656
select TVIN_VDIN
default n
---help---
Amlogic capture driver.
Say Y here if you want this driver.
Amlogic capture driver.
Say Y here if you want this driver.
config AMLOGIC_VIDEO_CAPTURE_OV5642
tristate "Amlogic Platform Capture Driver for OV5642"
depends on AMLOGIC_VIDEO_CAPTURE
select VIDEOBUF_VMALLOC
select AMLOGIC_VIDEOIN_MANAGER
select TVIN
select TVIN_BT656
select TVIN_VDIN
default n
---help---
Amlogic capture driver.
Say Y here if you want this driver.
Amlogic capture driver.
Say Y here if you want this driver.
choice
prompt "OV5642 AUTO FOCUS FIRMWARE"
depends on AMLOGIC_VIDEO_CAPTURE_OV5642
default NO_AUTO_FUCOS
config NO_AUTO_FUCOS
bool "NONE"
---help---
no auto focus
no auto focus
no auto focus
no auto focus
config AD5820
bool "AD5820"
---help---
AD5820
AD5820
AD5820
AD5820
config DW9714
bool "DW9714"
---help---
DW9714
DW9714
DW9714
DW9714
config AP5120
bool "AP5120"
---help---
AP5120
AP5120
AP5120
AP5120
endchoice
config AMLOGIC_VIDEO_CAPTURE_OV7675
tristate "Amlogic Platform Capture Driver for OV7675"
depends on AMLOGIC_VIDEO_CAPTURE
select VIDEOBUF_VMALLOC
select AMLOGIC_VIDEOIN_MANAGER
select TVIN
select TVIN_BT656
select TVIN_VDIN
default n
---help---
Amlogic capture driver.
Say Y here if you want this driver.
Amlogic capture driver.
Say Y here if you want this driver.
config AMLOGIC_VIDEO_CAPTURE_OV2655
tristate "Amlogic Platform Capture Driver for OV2655"
depends on AMLOGIC_VIDEO_CAPTURE
select VIDEOBUF_VMALLOC
select AMLOGIC_VIDEOIN_MANAGER
select TVIN
select TVIN_BT656
select TVIN_VDIN
default n
---help---
Amlogic capture driver.
Say Y here if you want this driver.
Amlogic capture driver.
Say Y here if you want this driver.
config AMLOGIC_VIDEO_CAPTURE_SP0838
tristate "Amlogic Platform Capture Driver for SP0838"
depends on AMLOGIC_VIDEO_CAPTURE
select VIDEOBUF_VMALLOC
select VIDEOBUF_RESOURCE
select AMLOGIC_VIDEOIN_MANAGER
select TVIN
select TVIN_BT656
select TVIN_VDIN
default n
---help---
Amlogic capture driver.
Say Y here if you want this driver.
Amlogic capture driver.
Say Y here if you want this driver.
config AMLOGIC_VIDEO_CAPTURE_SP2518
tristate "Amlogic Platform Capture Driver for SP2518"
depends on AMLOGIC_VIDEO_CAPTURE
select VIDEOBUF_VMALLOC
select VIDEOBUF_RESOURCE
select AMLOGIC_VIDEOIN_MANAGER
select TVIN
select TVIN_BT656
select TVIN_VDIN
default n
---help---
Amlogic capture driver.
Say Y here if you want this driver.
Amlogic capture driver.
Say Y here if you want this driver.
config AMLOGIC_VIDEO_CAPTURE_SP0A19
tristate "Amlogic Platform Capture Driver for SP0A19"
depends on AMLOGIC_VIDEO_CAPTURE
select VIDEOBUF_VMALLOC
select AMLOGIC_VIDEOIN_MANAGER
select TVIN
select TVIN_BT656
select TVIN_VDIN
default n
---help---
Amlogic capture driver.
Say Y here if you want this driver.
Amlogic capture driver.
Say Y here if you want this driver.
config AMLOGIC_VIDEO_CAPTURE_SP1628
tristate "Amlogic Platform Capture Driver for SP1628"
depends on AMLOGIC_VIDEO_CAPTURE
select VIDEOBUF_VMALLOC
select AMLOGIC_VIDEOIN_MANAGER
select TVIN
select TVIN_BT656
select TVIN_VDIN
default n
---help---
Amlogic capture driver.
Say Y here if you want this driver.
Amlogic capture driver.
Say Y here if you want this driver.
config AMLOGIC_VIDEO_CAPTURE_HI253
tristate "Amlogic Platform Capture Driver for HI253"
depends on AMLOGIC_VIDEO_CAPTURE
select VIDEOBUF_VMALLOC
select AMLOGIC_VIDEOIN_MANAGER
select TVIN
select TVIN_BT656
select TVIN_VDIN
default n
---help---
Amlogic capture driver.
Say Y here if you want this driver.
Amlogic capture driver.
Say Y here if you want this driver.
config AMLOGIC_VIDEO_CAPTURE_HI704
tristate "Amlogic Platform Capture Driver for HI704"
depends on AMLOGIC_VIDEO_CAPTURE
select VIDEOBUF_VMALLOC
select AMLOGIC_VIDEOIN_MANAGER
select TVIN
select TVIN_BT656
select TVIN_VDIN
default n
---help---
Amlogic capture driver.
Say Y here if you want this driver.
Amlogic capture driver.
Say Y here if you want this driver.
config AMLOGIC_VIDEO_CAPTURE_HM2057
tristate "Amlogic Platform Capture Driver for HM2057"
depends on AMLOGIC_VIDEO_CAPTURE
select VIDEOBUF_VMALLOC
select AMLOGIC_VIDEOIN_MANAGER
select TVIN
select TVIN_BT656
select TVIN_VDIN
default n
---help---
Amlogic capture driver.
Say Y here if you want this driver.
Amlogic capture driver.
Say Y here if you want this driver.
config AMLOGIC_VIDEO_CAPTURE_HM5065
tristate "Amlogic Platform Capture Driver for HM5065"
depends on AMLOGIC_VIDEO_CAPTURE
select VIDEOBUF_VMALLOC
select AMLOGIC_VIDEOIN_MANAGER
select TVIN
select TVIN_BT656
select TVIN_VDIN
default n
---help---
Amlogic capture driver.
Say Y here if you want this driver.
Amlogic capture driver.
Say Y here if you want this driver.
config AMLOGIC_VIDEO_CAPTURE_HM1375
tristate "Amlogic Platform Capture Driver for HM1375"
depends on AMLOGIC_VIDEO_CAPTURE
select VIDEOBUF_VMALLOC
select AMLOGIC_VIDEOIN_MANAGER
select TVIN
select TVIN_BT656
select TVIN_VDIN
default n
---help---
Amlogic capture driver.
Say Y here if you want this driver.
Amlogic capture driver.
Say Y here if you want this driver.
config AMLOGIC_VIDEO_CAPTURE_OV3660
tristate "Amlogic Platform Capture Driver for OV3660"
depends on AMLOGIC_VIDEO_CAPTURE
select VIDEOBUF_VMALLOC
select AMLOGIC_VIDEOIN_MANAGER
select TVIN
select TVIN_BT656
select TVIN_VDIN
default n
---help---
Amlogic capture driver.
Say Y here if you want this driver.
Amlogic capture driver.
Say Y here if you want this driver.
config AMLOGIC_VIDEO_CAPTURE_OV5647
tristate "Amlogic Platform Capture Driver for OV5647"
depends on AMLOGIC_VIDEO_CAPTURE
select VIDEOBUF_VMALLOC
select AMLOGIC_VIDEOIN_MANAGER
select TVIN
select TVIN_BT656
select TVIN_VDIN
default n
---help---
Amlogic capture driver.
Say Y here if you want this driver.
Amlogic capture driver.
Say Y here if you want this driver.
config AMLOGIC_VIDEO_CAPTURE_HI2056
tristate "Amlogic Platform Capture Driver for HI2056"
depends on AMLOGIC_VIDEO_CAPTURE
select VIDEOBUF_VMALLOC
select AMLOGIC_MIPI
default n
---help---
Amlogic capture driver.
Say Y here if you want this driver.
Amlogic capture driver.
Say Y here if you want this driver.
config AMLOGIC_VIDEO_CAPTURE_NT99250
tristate "Amlogic Platform Capture Driver for NT99250"
depends on AMLOGIC_VIDEO_CAPTURE
select VIDEOBUF_VMALLOC
select AMLOGIC_VIDEOIN_MANAGER
select TVIN
select TVIN_BT656
select TVIN_VDIN
default n
---help---
Amlogic capture driver.
Say Y here if you want this driver.
Amlogic capture driver.
Say Y here if you want this driver.
config AMLOGIC_VIDEO_CAPTURE_NT99252
tristate "Amlogic Platform Capture Driver for NT99252"
depends on AMLOGIC_VIDEO_CAPTURE
select VIDEOBUF_VMALLOC
select AMLOGIC_VIDEOIN_MANAGER
select TVIN
select TVIN_BT656
select TVIN_VDIN
default n
---help---
Amlogic capture driver.
Say Y here if you want this driver.
Amlogic capture driver.
Say Y here if you want this driver.
config AMLOGIC_VIDEO_CAPTURE_NT99340
tristate "Amlogic Platform Capture Driver for NT99340"
depends on AMLOGIC_VIDEO_CAPTURE
select VIDEOBUF_VMALLOC
select AMLOGIC_VIDEOIN_MANAGER
select TVIN
select TVIN_BT656
select TVIN_VDIN
default n
---help---
Amlogic capture driver.
Say Y here if you want this driver.
Amlogic capture driver.
Say Y here if you want this driver.
config AMLOGIC_VIDEO_CAPTURE_AR0543
tristate "Amlogic Platform Capture Driver for AR0543"
depends on AMLOGIC_VIDEO_CAPTURE
select VIDEOBUF_VMALLOC
select AMLOGIC_VIDEOIN_MANAGER
default n
---help---
Amlogic capture driver.
Say Y here if you want this driver.
Amlogic capture driver.
Say Y here if you want this driver.
config AMLOGIC_VIDEO_CAPTURE_AR0833
tristate "Amlogic Platform Capture Driver for AR0833"
depends on AMLOGIC_VIDEO_CAPTURE
select VIDEOBUF_VMALLOC
select AMLOGIC_VIDEOIN_MANAGER
default n
---help---
Amlogic capture driver.
Say Y here if you want this driver.
Amlogic capture driver.
Say Y here if you want this driver.
config AMLOGIC_VIDEO_CAPTURE_BF3720
tristate "Amlogic Platform Capture Driver for BF3720"
depends on AMLOGIC_VIDEO_CAPTURE
select VIDEOBUF_VMALLOC
select AMLOGIC_VIDEOIN_MANAGER
select TVIN
select TVIN_BT656
select TVIN_VDIN
default n
---help---
Amlogic capture driver.
Say Y here if you want this driver.
Amlogic capture driver.
Say Y here if you want this driver.
config AMLOGIC_VIDEOIN_MANAGER
tristate "amlogic video manager"
default n
---help---
this a test for video manager
endmenu

View File

@@ -0,0 +1,15 @@
#
# Makefile for the amlogic platform camera interface device drivers.
#
amlflash-objs := common/flashlight.o
amlcamera-objs := common/plat_ctrl.o
#common/util.o
amlvm-objs := common/vm.o
cam_prober-objs := common/cam_prober.o common/config_parser.o
gc2145dri-objs := gc2145.o
obj-y += amlflash.o
obj-y += amlvm.o
obj-y += amlcamera.o
obj-y += cam_prober.o
obj-$(CONFIG_AMLOGIC_VIDEO_CAPTURE_GC2145) += gc2145dri.o

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,301 @@
/*
* drivers/amlogic/media/camera/common/config_parser.h
*
* Copyright (C) 2017 Amlogic, Inc. All rights reserved.
*
* 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.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
*/
#ifndef CONFIG_PARSER
#define CONFIG_PARSER
#include <linux/kernel.h>
#include <linux/slab.h>
#include <linux/mm.h>
#include <linux/i2c.h>
#include <linux/string.h>
#include <linux/amlogic/media/frame_provider/tvin/tvin_v4l2.h>
#define EFFECT_ITEM_MAX 16
#define AET_ITEM_MAX 32
#define HW_ITEM_MAX 16
#define WB_ITEM_MAX 10
#define CAPTURE_ITEM_MAX 9
#define NR_ITEM_MAX 5
#define PEAKING_ITEM_MAX 5
#define LENS_ITEM_MAX 5
#define SCENE_ITEM_MAX 1
#define EFFECT_MAX 18
#define HW_MAX 64
#define WB_MAX 2
#define GAMMA_MAX 257
#define SCENE_MAX 281
#define WB_SENSOR_MAX 4
#define CAPTURE_MAX 8
#define LENS_MAX 1027
#define WAVE_MAX 12
#define CM_MAX 188
#define NR_MAX 15
#define PEAKING_MAX 35
#define AE_LEN 119
#define AWB_LEN 120
#define AF_LEN 42
#define BUFFER_SIZE 1024
enum error_code {
NO_MEM = 1,
READ_ERROR,
WRONG_FORMAT,
CHECK_LEN_FAILED,
CHECK_FAILED,
HEAD_FAILED,
BODY_HEAD_FAILED,
BODY_ELEMENT_FAILED,
};
struct effect_type {
int num;
char name[40];
unsigned int export[EFFECT_MAX];
};
struct effect_struct {
int sum;
struct effect_type eff[EFFECT_ITEM_MAX];
};
struct hw_type {
int num;
char name[40];
int export[HW_MAX];
};
struct hw_struct {
int sum;
struct hw_type hw[HW_ITEM_MAX];
};
struct wb_type {
int num;
char name[40];
int export[2];
};
struct wb_struct {
int sum;
struct wb_type wb[WB_ITEM_MAX];
};
struct scene_type {
int num;
char name[40];
int export[SCENE_MAX];
};
struct scene_struct {
int sum;
struct scene_type scene[SCENE_ITEM_MAX];
};
struct capture_type {
int num;
char name[40];
int export[CAPTURE_ITEM_MAX];
};
struct capture_struct {
int sum;
struct capture_type capture[CAPTURE_MAX];
};
struct sensor_aet_s {
unsigned int exp;
unsigned int ag;
unsigned int vts;
unsigned int gain;
unsigned int fr;
};
/* sensor_aet_t */
struct sensor_aet_info_s {
unsigned int fmt_main_fr;
unsigned int fmt_capture; /* false: preview, true: capture */
unsigned int fmt_hactive;
unsigned int fmt_vactive;
unsigned int fmt_rated_fr;
unsigned int fmt_min_fr;
unsigned int tbl_max_step;
unsigned int tbl_rated_step;
unsigned int tbl_max_gain;
unsigned int tbl_min_gain;
unsigned int format_transfer_parameter;
};
/* sensor_aet_info_t */
struct aet_type {
int num;
char name[40];
struct sensor_aet_info_s *info;
struct sensor_aet_s *aet_table;
};
struct aet_struct {
int sum;
struct aet_type aet[AET_ITEM_MAX];
};
struct wave_struct {
int export[WAVE_MAX];
};
struct lens_type {
int num;
char name[40];
int export[LENS_MAX];
};
struct lens_struct {
int sum;
struct lens_type lens[LENS_ITEM_MAX];
};
struct gamma_struct {
unsigned int gamma_r[GAMMA_MAX];
unsigned int gamma_g[GAMMA_MAX];
unsigned int gamma_b[GAMMA_MAX];
};
struct wb_sensor_struct {
int export[WB_SENSOR_MAX];
};
struct version_struct {
char date[40];
char module[30];
char version[30];
};
struct cm_struct {
int export[CM_MAX];
};
struct nr_type {
int num;
char name[40];
int export[NR_MAX];
};
struct nr_struct {
int sum;
struct nr_type nr[NR_ITEM_MAX];
};
struct peaking_type {
int num;
char name[40];
int export[PEAKING_MAX];
};
struct peaking_struct {
int sum;
struct peaking_type peaking[PEAKING_ITEM_MAX];
};
struct configure_s {
struct effect_struct eff;
int effect_valid;
struct hw_struct hw;
int hw_valid;
struct aet_struct aet;
int aet_valid;
struct capture_struct capture;
int capture_valid;
struct scene_struct scene;
int scene_valid;
struct wb_struct wb;
int wb_valid;
struct wave_struct wave;
int wave_valid;
struct lens_struct lens;
int lens_valid;
struct gamma_struct gamma;
int gamma_valid;
struct wb_sensor_struct wb_sensor_data;
int wb_sensor_data_valid;
struct version_struct version;
int version_info_valid;
struct cm_struct cm;
int cm_valid;
struct nr_struct nr;
int nr_valid;
struct peaking_struct peaking;
int peaking_valid;
};
struct para_index_s {
unsigned int effect_index;
unsigned int scenes_index;
unsigned int wb_index;
unsigned int capture_index;
unsigned int nr_index;
unsigned int peaking_index;
unsigned int lens_index;
};
struct wb_pair_t {
enum camera_wb_flip_e wb;
char *name;
};
struct effect_pair_t {
enum camera_special_effect_e effect;
char *name;
};
struct sensor_dg_s {
unsigned short r;
unsigned short g;
unsigned short b;
unsigned short dg_default;
};
struct camera_priv_data_s {
struct sensor_aet_info_s
*sensor_aet_info; /* point to 1 of up to 16 aet information */
struct sensor_aet_s *sensor_aet_table;
unsigned int sensor_aet_step; /* current step of the current aet */
struct configure_s *configure;
};
int parse_config(const char *path, struct configure_s *cf);
int generate_para(struct cam_parameter_s *para, struct para_index_s pindex,
struct configure_s *cf);
void free_para(struct cam_parameter_s *para);
int update_fmt_para(int width, int height, struct cam_parameter_s *para,
struct para_index_s *pindex, struct configure_s *cf);
unsigned int get_aet_current_step(void *priv);
unsigned int get_aet_current_gain(void *pirv);
unsigned int get_aet_min_gain(void *priv);
unsigned int get_aet_max_gain(void *priv);
unsigned int get_aet_max_step(void *priv);
unsigned int get_aet_gain_by_step(void *priv, unsigned int new_step);
int my_i2c_put_byte(struct i2c_adapter *adapter, unsigned short i2c_addr,
unsigned short addr, unsigned char data);
int my_i2c_put_byte_add8(struct i2c_adapter *adapter, unsigned short i2c_addr,
char *buf, int len);
int my_i2c_get_byte(struct i2c_adapter *adapter, unsigned short i2c_addr,
unsigned short addr);
int my_i2c_get_word(struct i2c_adapter *adapter, unsigned short i2c_addr);
#endif

View File

@@ -0,0 +1,249 @@
/*
* drivers/amlogic/media/camera/common/flashlight.c
*
* Copyright (C) 2017 Amlogic, Inc. All rights reserved.
*
* 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.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
*/
#include <linux/cdev.h>
#include <linux/types.h>
#include <linux/fs.h>
#include <linux/device.h>
#include <linux/platform_device.h>
#include <linux/amlogic/media/camera/flashlight.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/err.h>
#define FLASHLIGHT_MODULE_NAME "flashlight"
#define FLASHLIGHT_DRIVER_NAME "flashlight"
#define FLASHLIGHT_DEVICE_NAME "flashlight"
#define FLASHLIGHT_CLASS_NAME "flashlight"
static dev_t flashlight_devno;
static struct cdev *flashlight_cdev;
static struct device *devp;
static enum aml_plat_flashlight_status_s flashlight_flag = FLASHLIGHT_OFF;
static ssize_t flashlight_ctrl_store(struct class *cla,
struct class_attribute *attr,
const char *buf, size_t count);
static ssize_t flashlightflag_show(struct class *cla,
struct class_attribute *attr, char *buf);
static ssize_t flashlightflag_store(struct class *cla,
struct class_attribute *attr,
const char *buf, size_t count);
static int flashlight_open(struct inode *inode, struct file *file);
static int flashlight_release(struct inode *inode, struct file *file);
static int flashlight_probe(struct platform_device *pdev);
static int flashlight_remove(struct platform_device *pdev);
static struct platform_driver flashlight_driver = {
.probe = flashlight_probe, .remove = flashlight_remove, .driver = {
.name =
FLASHLIGHT_DRIVER_NAME, .owner = THIS_MODULE,
},
};
static const struct file_operations flashlight_fops = {
.open = flashlight_open, .release = flashlight_release,
};
static struct class_attribute flashlight_class_attrs[] = {
__ATTR(flashlight_ctrl, 0644, NULL, flashlight_ctrl_store),
__ATTR(flashlightflag, 0644, flashlightflag_show,
flashlightflag_store),
__ATTR_NULL
};
static struct class flashlight_class = {
.name = FLASHLIGHT_CLASS_NAME,
.class_attrs = flashlight_class_attrs,
.owner = THIS_MODULE,
};
static ssize_t flashlight_ctrl_store(struct class *cla,
struct class_attribute *attr,
const char *buf, size_t count)
{
struct aml_plat_flashlight_data_s *pdata = NULL;
struct device *dev = NULL;
dev = devp;
pdata = (struct aml_plat_flashlight_data_s *)dev->platform_data;
if (pdata == NULL) {
pr_err("%s platform data is required!\n", __func__);
return -1;
}
if (!strncmp(buf, "0", 1)) {
if (pdata->flashlight_off)
pdata->flashlight_off();
} else if (!strncmp(buf, "1", 1)) {
if (pdata->flashlight_on)
pdata->flashlight_on();
} else {
pr_err("%s:%s error!Not support this parameter\n",
FLASHLIGHT_MODULE_NAME, __func__);
return -EINVAL;
}
return count;
}
static ssize_t flashlightflag_show(struct class *cla,
struct class_attribute *attr, char *buf)
{
sprintf(buf, "%d", (int)flashlight_flag);
return strlen(buf);
}
static ssize_t flashlightflag_store(struct class *cla,
struct class_attribute *attr,
const char *buf, size_t count)
{
if (!strlen(buf))
pr_info("%s parameter is required!\n", __func__);
flashlight_flag = (enum aml_plat_flashlight_status_s)(buf[0] - '0');
return count;
}
static int flashlight_open(struct inode *inode, struct file *file)
{
return 0;
}
static int flashlight_release(struct inode *inode, struct file *file)
{
return 0;
}
static int flashlight_probe(struct platform_device *pdev)
{
int ret;
struct aml_plat_flashlight_data_s *pdata = NULL;
ret = alloc_chrdev_region(&flashlight_devno, 0,
1, FLASHLIGHT_DRIVER_NAME);
if (ret < 0) {
pr_err("%s:%s failed to allocate major number\n",
FLASHLIGHT_MODULE_NAME, __func__);
ret = -ENODEV;
goto out;
}
ret = class_register(&flashlight_class);
if (ret < 0) {
pr_err("%s:%s failed to register class\n",
FLASHLIGHT_MODULE_NAME, __func__);
goto error1;
}
flashlight_cdev = cdev_alloc();
if (!flashlight_cdev) {
pr_err("%s:%s: failed to allocate memory\n",
FLASHLIGHT_MODULE_NAME, __func__);
ret = -ENOMEM;
goto error2;
}
cdev_init(flashlight_cdev, &flashlight_fops);
flashlight_cdev->owner = THIS_MODULE;
ret = cdev_add(flashlight_cdev, flashlight_devno, 1);
if (ret) {
pr_err("%s:%s: failed to add device\n",
FLASHLIGHT_MODULE_NAME, __func__);
goto error3;
}
devp = device_create(&flashlight_class, NULL, flashlight_devno, NULL,
FLASHLIGHT_DEVICE_NAME);
if (IS_ERR(devp)) {
pr_err("%s:%s failed to create device node\n",
FLASHLIGHT_MODULE_NAME, __func__);
ret = PTR_ERR(devp);
goto error3;
}
pr_info("%s:%s device %s created\n", FLASHLIGHT_MODULE_NAME,
__func__, FLASHLIGHT_DEVICE_NAME);
pdata = pdev->dev.platform_data;
if (!pdata) {
dev_err(&pdev->dev, "platform data is required!\n");
ret = -EINVAL;
goto error4;
}
devp->platform_data = pdata;
return 0;
error4:
device_destroy(NULL, flashlight_devno);
error3:
cdev_del(flashlight_cdev);
error2:
class_unregister(&flashlight_class);
error1:
unregister_chrdev_region(flashlight_devno, 1);
out:
return ret;
}
static int flashlight_remove(struct platform_device *pdev)
{
unregister_chrdev_region(flashlight_devno, 1);
class_unregister(&flashlight_class);
device_destroy(NULL, flashlight_devno);
cdev_del(flashlight_cdev);
return 0;
}
int set_flashlight(bool mode)
{
struct aml_plat_flashlight_data_s *pdata = NULL;
if (devp && devp->platform_data) {
pdata = devp->platform_data;
if (!mode) {
if (pdata->flashlight_off)
pdata->flashlight_off();
} else {
if (pdata->flashlight_on)
pdata->flashlight_on();
}
}
return 0;
}
EXPORT_SYMBOL(set_flashlight);
enum aml_plat_flashlight_status_s get_flashlightflag(void)
{
return flashlight_flag;
}
EXPORT_SYMBOL(get_flashlightflag);
static int __init flashlight_init(void)
{
int ret = -1;
ret = platform_driver_register(&flashlight_driver);
if (ret != 0) {
pr_err("failed to register flashlight driver,error %d\n", ret);
return -ENODEV;
}
return ret;
}
static void __exit flashlight_exit(void)
{
platform_driver_unregister(&flashlight_driver);
}
module_init(flashlight_init);
module_exit(flashlight_exit);
MODULE_DESCRIPTION("AMLOGIC flashlight driver");
MODULE_LICENSE("GPL");
MODULE_AUTHOR("amlogic");

View File

@@ -0,0 +1,208 @@
/*
* drivers/amlogic/media/camera/common/plat_ctrl.c
*
* Copyright (C) 2017 Amlogic, Inc. All rights reserved.
*
* 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.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
*/
#include <linux/module.h>
#include <linux/delay.h>
#include <linux/errno.h>
#include <linux/fs.h>
#include <linux/kernel.h>
#include <linux/wait.h>
#include <linux/slab.h>
#include <linux/mm.h>
#include <linux/ioport.h>
#include <linux/init.h>
#include <linux/sched.h>
#include <linux/pci.h>
#include <linux/random.h>
#include <linux/version.h>
#include <linux/mutex.h>
#include <linux/videodev2.h>
#include <linux/dma-mapping.h>
#include <linux/interrupt.h>
#include <linux/kthread.h>
#include <linux/highmem.h>
#include <linux/freezer.h>
#include <media/videobuf-vmalloc.h>
#include <linux/i2c.h>
#include "plat_ctrl.h"
/****************************************************************
* i2c functions
* **************************************************************/
static int camera_read_buff(struct i2c_client *client, char *buf, int addr_len,
int data_len)
{
int i2c_flag = -1;
struct i2c_msg msgs[] = {{
.addr = client->addr, .flags = 0,
.len = addr_len, .buf = buf,
}, {
.addr = client->addr, .flags = I2C_M_RD,
.len = data_len, .buf = buf,
}
};
i2c_flag = i2c_transfer(client->adapter, msgs, 2);
return i2c_flag;
}
static int camera_write_buff(struct i2c_client *client, char *buf, int len)
{
struct i2c_msg msg[] = {{
.addr = client->addr, .flags = 0, /* |I2C_M_TEN, */
.len = len, .buf = buf,
}
};
if (i2c_transfer(client->adapter, msg, 1) < 0) {
pr_err("i2c error\n");
return -1;
} else
return 0;
}
int i2c_get_byte(struct i2c_client *client, unsigned short addr)
{
unsigned char buff[4];
buff[0] = (unsigned char)((addr >> 8) & 0xff);
buff[1] = (unsigned char)(addr & 0xff);
if (camera_read_buff(client, buff, 2, 1) < 0)
return -1;
return buff[0];
}
int i2c_get_byte_add8(struct i2c_client *client, unsigned char addr)
{
unsigned char buff[4];
buff[0] = (unsigned char)(addr & 0xff);
if (camera_read_buff(client, buff, 1, 1) < 0)
return -1;
return buff[0];
}
int i2c_get_word(struct i2c_client *client, unsigned short addr)
{
unsigned short data;
unsigned char buff[4];
buff[0] = (unsigned char)((addr >> 8) & 0xff);
buff[1] = (unsigned char)(addr & 0xff);
if (camera_read_buff(client, buff, 2, 2) < 0)
return -1;
data = buff[0];
data = (data << 8) | buff[1];
return data;
}
int i2c_put_byte(struct i2c_client *client, unsigned short addr,
unsigned char data)
{
unsigned char buff[4];
buff[0] = (unsigned char)((addr >> 8) & 0xff);
buff[1] = (unsigned char)(addr & 0xff);
buff[2] = data;
if (camera_write_buff(client, buff, 3) < 0)
return -1;
return 0;
}
int i2c_put_word(struct i2c_client *client, unsigned short addr,
unsigned short data)
{
unsigned char buff[4];
buff[0] = (unsigned char)((addr >> 8) & 0xff);
buff[1] = (unsigned char)(addr & 0xff);
buff[2] = (unsigned char)((data >> 8) & 0xff);
buff[3] = (unsigned char)(data & 0xff);
if (camera_write_buff(client, buff, 4) < 0)
return -1;
return 0;
}
int i2c_put_byte_add8_new(struct i2c_client *client, unsigned char addr,
unsigned char data)
{
unsigned char buff[4];
buff[0] = (unsigned char)(addr & 0xff);
buff[1] = (unsigned char)(data & 0xff);
if (camera_write_buff(client, buff, 2) < 0)
return -1;
return 0;
}
int i2c_put_byte_add8(struct i2c_client *client, char *buf, int len)
{
if (camera_write_buff(client, buf, len) < 0)
return -1;
return 0;
}
int cam_i2c_send_msg(struct i2c_client *client, struct cam_i2c_msg_s i2c_msg)
{
unsigned char buff[4];
switch (i2c_msg.type) {
case ADDR16_DATA16:
buff[0] = (unsigned char)((i2c_msg.addr >> 8) & 0xff);
buff[1] = (unsigned char)(i2c_msg.addr & 0xff);
buff[2] = (unsigned char)((i2c_msg.data >> 8) & 0xff);
buff[3] = (unsigned char)(i2c_msg.data & 0xff);
if (camera_write_buff(client, buff, 4) < 0)
return -1;
break;
case ADDR16_DATA8:
buff[0] = (unsigned char)((i2c_msg.addr >> 8) & 0xff);
buff[1] = (unsigned char)(i2c_msg.addr & 0xff);
buff[2] = (unsigned char)(i2c_msg.data & 0xff);
if (camera_write_buff(client, buff, 3) < 0)
return -1;
break;
case ADDR8_DATA16:
buff[0] = (unsigned char)(i2c_msg.addr & 0xff);
buff[1] = (unsigned char)((i2c_msg.data >> 8) & 0xff);
buff[2] = (unsigned char)(i2c_msg.data & 0xff);
if (camera_write_buff(client, buff, 3) < 0)
return -1;
break;
case ADDR8_DATA8:
buff[0] = (unsigned char)(i2c_msg.addr & 0xff);
buff[1] = (unsigned char)(i2c_msg.data & 0xff);
if (camera_write_buff(client, buff, 2) < 0)
return -1;
break;
case TIME_DELAY:
msleep(i2c_msg.data);
break;
default:
break;
}
return 0;
}

View File

@@ -0,0 +1,47 @@
/*
* drivers/amlogic/media/camera/common/plat_ctrl.h
*
* Copyright (C) 2017 Amlogic, Inc. All rights reserved.
*
* 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.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
*/
#ifndef _AMLOGIC_CAMERA_PLAT_CTRL_H
#define _AMLOGIC_CAMERA_PLAT_CTRL_H
#define ADDR8_DATA8 0
#define ADDR16_DATA8 1
#define ADDR16_DATA16 2
#define ADDR8_DATA16 3
#define TIME_DELAY 0xfe
#define END_OF_SCRIPT 0xff
struct cam_i2c_msg_s {
unsigned char type;
unsigned short addr;
unsigned short data;
};
extern int i2c_get_byte(struct i2c_client *client, unsigned short addr);
extern int i2c_get_word(struct i2c_client *client, unsigned short addr);
extern int i2c_get_byte_add8(struct i2c_client *client, unsigned char addr);
extern int i2c_put_byte(struct i2c_client *client, unsigned short addr,
unsigned char data);
extern int i2c_put_word(struct i2c_client *client, unsigned short addr,
unsigned short data);
extern int i2c_put_byte_add8_new(struct i2c_client *client, unsigned char addr,
unsigned char data);
extern int i2c_put_byte_add8(struct i2c_client *client, char *buf, int len);
extern int cam_i2c_send_msg(struct i2c_client *client,
struct cam_i2c_msg_s i2c_msg);
#endif /* _AMLOGIC_CAMERA_PLAT_CTRL_H. */

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,139 @@
/*
* drivers/amlogic/media/camera/common/vm.h
*
* Copyright (C) 2017 Amlogic, Inc. All rights reserved.
*
* 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.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
*/
#ifndef _VM_INCLUDE__
#define _VM_INCLUDE__
#include <linux/interrupt.h>
#include <linux/amlogic/media/canvas/canvas.h>
#include <linux/fb.h>
#include <linux/list.h>
#include <linux/uaccess.h>
#include <linux/sysfs.h>
#include <linux/spinlock.h>
#include <linux/kthread.h>
#include <linux/io-mapping.h>
#include <linux/wait.h>
#include <linux/semaphore.h>
#include <linux/cdev.h>
#include <linux/amlogic/media/vfm/vframe_receiver.h>
#include <linux/amlogic/media/vfm/vframe_provider.h>
#include <linux/amlogic/media/camera/aml_cam_info.h>
#include <linux/amlogic/media/camera/vmapi.h>
/*************************************
**
** macro define
**
*************************************/
#define VM_IOC_MAGIC 'P'
#define VM_IOC_2OSD0 _IOW(VM_IOC_MAGIC, 0x00, unsigned int)
#define VM_IOC_ENABLE_PP _IOW(VM_IOC_MAGIC, 0X01, unsigned int)
#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];
struct platform_device *pdev;
int dump;
char *dump_path;
unsigned int open_count;
int major;
unsigned int dbg_enable;
/* struct class *cla; */
struct cdev cdev;
struct device *dev;
resource_size_t buffer_start;
unsigned int buffer_size;
#ifdef CONFIG_CMA
ulong cma_pool_size;
#endif
struct vframe_receiver_s vm_vf_recv;
struct task_struct *task;
wait_queue_head_t frame_ready;
int task_running;
int vm_skip_count;
int test_zoom;
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];
};
struct display_frame_s {
int frame_top;
int frame_left;
int frame_width;
int frame_height;
int content_top;
int content_left;
int content_width;
int content_height;
};
int start_vm_task(struct vm_device_s *vdevp);
int start_simulate_task(void);
extern int get_vm_status(void);
extern void set_vm_status(int flag);
/* for vm device op. */
extern int init_vm_device(struct vm_device_s *vdevp,
struct platform_device *pdev);
extern int uninit_vm_device(struct platform_device *plat_dev);
/* for vm device class op. */
extern struct class *init_vm_cls(void);
/* for thread of vm. */
extern int start_vpp_task(void);
extern void stop_vpp_task(void);
/* for vm private member. */
extern void set_vm_buf_info(resource_size_t start, unsigned int size);
extern void get_vm_buf_info(resource_size_t *start, unsigned int *size,
struct io_mapping **mapping);
/* vm buffer op. */
extern int vm_buffer_init(struct vm_device_s *vdevp);
extern void vm_local_init(void);
extern void vm_deinit_resource(struct vm_init_s *info);
static DEFINE_MUTEX(vm_mutex);
/* #if MESON_CPU_TYPE >= MESON_CPU_TYPE_MESON6TV */
#if 1
#define CANVAS_WIDTH_ALIGN 32
#else
#define CANVAS_WIDTH_ALIGN 8
#endif
#define MAGIC_SG_MEM 0x17890714
#define MAGIC_DC_MEM 0x0733ac61
#define MAGIC_VMAL_MEM 0x18221223
#define MAGIC_RE_MEM 0x123039dc
#endif /* _VM_INCLUDE__ */

View File

@@ -0,0 +1,44 @@
/*
* drivers/amlogic/media/camera/common/vm_log.h
*
* Copyright (C) 2017 Amlogic, Inc. All rights reserved.
*
* 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.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
*/
#ifndef VM_LOG_H
#define VM_LOG_H
#define DEBUG
#ifdef DEBUG
#define AMLOG 1
#define LOG_LEVEL_VAR amlog_level_ppmgr
#define LOG_MASK_VAR amlog_mask_ppmgr
#endif
#define LOG_LEVEL_HIGH 0x00f
#define LOG_LEVEL_1 0x001
#define LOG_LEVEL_LOW 0x000
#define LOG_LEVEL_DESC \
"[0x00]LOW[0X01]LEVEL1[0xf]HIGH"
#define LOG_MASK_INIT 0x001
#define LOG_MASK_IOCTL 0x002
#define LOG_MASK_HARDWARE 0x004
#define LOG_MASK_CONFIG 0x008
#define LOG_MASK_WORK 0x010
#define LOG_MASK_DESC \
"[0x01]:INIT,[0x02]:IOCTL,[0x04]:HARDWARE,[0x08]LOG_MASK_CONFIG[0x10]LOG_MASK_WORK"
#endif

View File

@@ -0,0 +1,189 @@
/*
* drivers/amlogic/media/camera/common/vmcls.h
*
* Copyright (C) 2017 Amlogic, Inc. All rights reserved.
*
* 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.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
*/
#define VM_CLASS_NAME "vm"
extern void interleave_uv(unsigned char *pU, unsigned char *pV,
unsigned char *pUV, unsigned int size_u_or_v);
static ssize_t show_vm_info(struct class *cla, struct class_attribute *attr,
char *buf)
{
#if 0
resource_size_t bstart;
unsigned int bsize;
get_vm_buf_info(&bstart, &bsize, NULL);
return snprintf(buf, 80, "buffer:\n start:%x.\tsize:%d\n",
(unsigned int)bstart, bsize / (1024 * 1024));
#endif
return 0;
}
static char attr_dat0[3] = "-1";
static ssize_t read_attr0(struct class *cla, struct class_attribute *attr,
char *buf)
{
return snprintf(buf, 3, "%s", attr_dat0);
}
static ssize_t write_attr0(struct class *cla,
struct class_attribute *attr,
const char *buf, size_t count)
{
/* struct display_device *dsp = dev_get_drvdata(dev); */
ssize_t ret = -EINVAL;
if (count <= 2) {
int i = 0;
if (buf[0] == '-') {
attr_dat0[0] = '-';
i = 1;
ret++;
}
if ((buf[i] >= '0') && (buf[i] <= '9')) {
attr_dat0[i] = buf[i];
attr_dat0[i + 1] = '\0';
ret++;
} else {
attr_dat0[0] = '-';
attr_dat0[1] = '1'; /* default -1; */
ret = -EINVAL;
}
}
return ret;
}
static char attr_dat1[3] = "-1";
static ssize_t read_attr1(struct class *cla, struct class_attribute *attr,
char *buf)
{
return snprintf(buf, 3, "%s", attr_dat1);
}
static ssize_t write_attr1(struct class *cla,
struct class_attribute *attr,
const char *buf, size_t count)
{
/* struct display_device *dsp = dev_get_drvdata(dev); */
ssize_t ret = -EINVAL;
if (count <= 2) {
int i = 0;
if (buf[0] == '-') {
attr_dat1[0] = '-';
i = 1;
ret++;
}
if ((buf[i] >= '0') && (buf[i] <= '9')) {
attr_dat1[i] = buf[i];
attr_dat1[i + 1] = '\0';
ret++;
} else {
attr_dat1[0] = '-';
attr_dat1[1] = '1'; /* default -1; */
ret = -EINVAL;
}
}
return ret;
}
int disable_gt2005;
static ssize_t read_attr2(struct class *cla, struct class_attribute *attr,
char *buf)
{
return disable_gt2005;
}
static ssize_t write_attr2(struct class *cla,
struct class_attribute *attr,
const char *buf, size_t count)
{
/* struct display_device *dsp = dev_get_drvdata(dev); */
ssize_t ret = -EINVAL;
if (count <= 2)
disable_gt2005 = buf[0];
return ret;
}
int camera_mirror_flag; /* 0: disable, 1: l&r mirror,2 t-b mirror */
static ssize_t mirror_read(struct class *cla, struct class_attribute *attr,
char *buf)
{
if (camera_mirror_flag == 1)
return snprintf(buf, 80,
"currnet mirror mode is l-r mirror mode. value is: %d.\n",
camera_mirror_flag);
else if (camera_mirror_flag == 2)
return snprintf(buf, 80,
"currnet mirror mode is t-b mirror mode. value is: %d.\n",
camera_mirror_flag);
else
return snprintf(buf, 80,
"currnet mirror mode is normal mode. value is: %d.\n",
camera_mirror_flag);
}
static ssize_t mirror_write(struct class *cla,
struct class_attribute *attr,
const char *buf, size_t count)
{
ssize_t size;
char *endp = "1";
camera_mirror_flag = kstrtoul(buf, 0, (unsigned long *)endp);
size = endp - buf;
return count;
}
static struct class_attribute vm_class_attrs[] = {
__ATTR(info, 0644,
show_vm_info, NULL),
__ATTR(attr0, 0644,
read_attr0, write_attr0),
__ATTR(attr1, 0644,
read_attr1, write_attr1),
__ATTR(attr2, 0644,
read_attr2, write_attr2),
__ATTR(mirror, 0644,
mirror_read, mirror_write),
__ATTR_NULL
};
static struct class vm_class = {
.name = VM_CLASS_NAME,
.class_attrs = vm_class_attrs,
};
struct class *init_vm_cls()
{
int ret = 0;
ret = class_register(&vm_class);
if (ret < 0) {
pr_err("error create vm class\n");
return NULL;
}
return &vm_class;
}

File diff suppressed because it is too large Load Diff

View File

@@ -521,9 +521,6 @@ static void canvas_pool_config(void)
canvas_pool_register_const_canvas(0x70, 0x77, "ppmgr");
canvas_pool_register_const_canvas(0xe4, 0xef, "encoder");
canvas_pool_register_const_canvas(0x40, 0x48, "osd");
#ifdef CONFIG_AMLOGIC_VIDEOIN_MANAGER
canvas_pool_register_const_canvas(0x4e, 0x5f, "vm");
#endif
canvas_pool_register_const_canvas(0xc0, 0xd7, "amlvideo2");
/*please add static canvas later. */
}

View File

@@ -368,17 +368,6 @@ static void vfm_init(void)
#ifdef CONFIG_TVIN_VIUIN
char def_ext_id[] = "default_ext";
char def_ext_name_chain[] = "vdin amvideo2";
#else /**/
#ifdef CONFIG_AMLOGIC_VIDEOIN_MANAGER
char def_ext_id0[] = "default_ext0";
char def_ext_id1[] = "default_ext1";
#ifdef CONFIG_AMLOGIC_VM_DISABLE_VIDEOLAYER
char def_ext_name_chain0[] = "vdin0 vm0";
char def_ext_name_chain1[] = "vdin1 vm1";
#else /**/
char def_ext_name_chain[] = "vdin0 vm amvideo";
#endif /**/
#endif /**/
#endif /**/
#ifdef CONFIG_VDIN_MIPI
char def_mipi_id[] = "default_mipi";
@@ -417,10 +406,7 @@ static void vfm_init(void)
#ifdef CONFIG_VDIN_MIPI
vfm_map_add(def_mipi_id, def_mipi_name_chain);
#endif /**/
#ifdef CONFIG_AMLOGIC_VIDEOIN_MANAGER
vfm_map_add(def_ext_id0, def_ext_name_chain0);
vfm_map_add(def_ext_id1, def_ext_name_chain1);
#endif /**/
#if (defined CONFIG_TVIN_AFE) || (defined CONFIG_TVIN_HDMI)
vfm_map_add(tvpath_id, tvpath_chain);
#endif /**/

View File

@@ -0,0 +1,142 @@
/*
* include/linux/amlogic/media/camera/aml_cam_info.h
*
* Copyright (C) 2017 Amlogic, Inc. All rights reserved.
*
* 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.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
*/
#ifndef __AML_CAM_DEV__
#define __AML_CAM_DEV__
#include <linux/list.h>
#include <linux/i2c.h>
#include <linux/amlogic/i2c-amlogic.h>
#include <linux/amlogic/media/frame_provider/tvin/tvin_v4l2.h>
#include <linux/amlogic/media/frame_provider/tvin/tvin.h>
#include <linux/amlogic/media/camera/flashlight.h>
#define FRONT_CAM 0
#define BACK_CAM 1
enum resolution_size {
SIZE_NULL = 0, SIZE_176X144, /* 4:3 */
SIZE_320X240, /* 4:3 */
SIZE_352X288, /* 4:3 */
SIZE_640X480, /* 0.3M 4:3 */
SIZE_720X405, /* 0.3M 16:9 */
SIZE_800X600, /* 0.5M 4:3 */
SIZE_960X540, /* 0.5M 16:9 */
SIZE_1024X576, /* 0.6M 16:9 */
SIZE_960X720, /* 0.7M 4:3 */
SIZE_1024X768, /* 0.8M 4:3 */
SIZE_1280X720, /* 0.9M 16:9 */
SIZE_1152X864, /* 1M 4:3 */
SIZE_1366X768, /* 1M 16:9 */
SIZE_1280X960, /* 1.2M 4:3 */
SIZE_1280X1024, /* 1.3M 16:9. */
SIZE_1400X1050, /* 1.5M 4:3 */
SIZE_1600X900, /* 1.5M 16:9 */
SIZE_1600X1200, /* 2M 4:3 */
SIZE_1920X1080, /* 2M 16:9 */
SIZE_1792X1344, /* 2.4M 4:3 */
SIZE_2048X1152, /* 2.4M 16:9 */
SIZE_2048X1536, /* 3.2M 4:3 */
SIZE_2304X1728, /* 4M 4:3 */
SIZE_2560X1440, /* 4M 16:9 */
SIZE_2592X1944, /* 5M 4:3 */
SIZE_3072X1728, /* 5M 16:9 */
SIZE_2816X2112, /* 6M 4:3 */
SIZE_3264X1836, /* 6m 16:9 */
SIZE_3072X2304, /* 7M 4:3 */
SIZE_3200X2400, /* 7.5M 4:3 */
SIZE_3264X2448, /* 8M 4:3 */
SIZE_3840X2160, /* 8M 16:9 */
SIZE_3456X2592, /* 9M 4:3 */
SIZE_3600X2700, /* 9.5M 4:3 */
SIZE_4096X2304, /* 9.5M 16:9 */
SIZE_3672X2754, /* 10M 4:3 */
SIZE_3840X2880, /* 11M 4:3 */
SIZE_4000X3000, /* 12M 4:3 */
SIZE_4608X2592, /* 12M 16:9 */
SIZE_4096X3072, /* 12.5M 4:3 */
SIZE_4800X3200, /* 15M 4:3 */
SIZE_5120X2880, /* 15M 16:9 */
SIZE_5120X3840, /* 20M 4:3 */
SIZE_6400X4800, /* 30M 4:3 */
};
typedef int (*aml_cam_probe_fun_t)(struct i2c_adapter *);
struct aml_cam_info_s {
struct list_head info_entry;
const char *name;
unsigned int i2c_bus_num;
unsigned int pwdn_act;
unsigned int front_back; /* front is 0, back is 1 */
unsigned int m_flip;
unsigned int v_flip;
unsigned int flash;
unsigned int auto_focus;
unsigned int i2c_addr;
const char *motor_driver;
const char *resolution;
const char *version;
unsigned int mclk;
unsigned int flash_support;
unsigned int flash_ctrl_level;
unsigned int torch_support;
unsigned int torch_ctrl_level;
unsigned int vcm_mode;
unsigned int spread_spectrum;
unsigned int vdin_path;
unsigned int bt_path_count;
enum bt_path_e bt_path;
enum cam_interface_e interface;
enum clk_channel_e clk_channel;
/* gpio_t pwdn_pin; */
/* gpio_t rst_pin; */
/* gpio_t flash_ctrl_pin; */
/* gpio_t torch_ctrl_pin; */
unsigned int pwdn_pin;
unsigned int rst_pin;
unsigned int flash_ctrl_pin;
unsigned int torch_ctrl_pin;
enum resolution_size max_cap_size;
enum tvin_color_fmt_e bayer_fmt;
const char *config;
struct pinctrl *camera_pin_ctrl;
};
/* aml_cam_info_t */
struct aml_camera_i2c_fig_s {
unsigned short addr;
unsigned char val;
};
struct aml_camera_i2c_fig0_s {
unsigned short addr;
unsigned short val;
};
struct aml_camera_i2c_fig1_s {
unsigned char addr;
unsigned char val;
};
extern void aml_cam_init(struct aml_cam_info_s *cam_dev);
extern void aml_cam_uninit(struct aml_cam_info_s *cam_dev);
extern void aml_cam_flash(struct aml_cam_info_s *cam_dev, int is_on);
extern void aml_cam_torch(struct aml_cam_info_s *cam_dev, int is_on);
extern int aml_cam_info_reg(struct aml_cam_info_s *cam_info);
extern int aml_cam_info_unreg(struct aml_cam_info_s *cam_info);
#endif /* __AML_CAM_DEV__ */

View File

@@ -0,0 +1,34 @@
/*
* include/linux/amlogic/media/camera/flashlight.h
*
* Copyright (C) 2017 Amlogic, Inc. All rights reserved.
*
* 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.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
*/
#ifndef _VIDEO_AMLOGIC_FLASHLIGHT_INCLUDE_
#define _VIDEO_AMLOGIC_FLASHLIGHT_INCLUDE_
struct aml_plat_flashlight_data_s {
void (*flashlight_on)(void);
void (*flashlight_off)(void);
};
enum aml_plat_flashlight_status_s {
FLASHLIGHT_AUTO = 0,
FLASHLIGHT_ON,
FLASHLIGHT_OFF,
FLASHLIGHT_TORCH,
FLASHLIGHT_RED_EYE,
};
#endif

View File

@@ -0,0 +1,63 @@
/*
* include/linux/amlogic/media/camera/vmapi.h
*
* Copyright (C) 2017 Amlogic, Inc. All rights reserved.
*
* 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.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
*/
#ifndef VM_API_INCLUDE_
#define VM_API_INCLUDE_
struct vm_output_para {
int width;
int height;
int bytesperline;
int v4l2_format;
int index;
int v4l2_memory;
int zoom; /* set -1 as invalid */
int mirror; /* set -1 as invalid */
int angle;
uintptr_t vaddr;/*unsigned*/
unsigned int ext_canvas;
};
/*struct vm_output_para*/
struct videobuf_buffer;
struct vb2_buffer;
struct vm_init_s {
size_t vm_buf_size;
struct page *vm_pages;
resource_size_t buffer_start;
unsigned int vdin_id;
unsigned int bt_path_count;
bool isused;
bool mem_alloc_succeed;
};
/*struct vm_init_s*/
int vm_fill_this_buffer(struct videobuf_buffer *vb, struct vm_output_para *para,
struct vm_init_s *info);
int vm_fill_buffer(struct videobuf_buffer *vb, struct vm_output_para *para);
int vm_fill_buffer2(struct vb2_buffer *vb, struct vm_output_para *para);
#ifdef CONFIG_CMA
int vm_init_buf(size_t size);
int vm_init_resource(size_t size, struct vm_init_s *info);
void vm_deinit_buf(void);
void vm_deinit_resource(struct vm_init_s *info);
void vm_reserve_cma(void);
#endif
#endif /* VM_API_INCLUDE_ */