31全志r58平台Android4.4.2下打开USB摄像头

 

31全志r58平台Android4.4.2下打开USB摄像头

 


2018/10/26 16:00

版本:V1.0

 

 

开发板:SC5806

 

 

1、系统编译:(略)

 

 

 

 

 

2、需要修改的文件:

W:\r58_android_v4.4\android\device\softwinner\octopus-common\hardware\camera\V4L2CameraDevice2.cpp

(这里不修改,你的USB摄像头是肯定打不开的!)

/****************************************************************************

 * V4L2CameraDevice interface implementation.

 ***************************************************************************/

 

status_t V4L2CameraDevice::connectDevice(HALCameraInfo * halInfo)

{

F_LOG;

 

    Mutex::Autolock locker(&mObjectLock);

 

if (isConnected())

{

LOGW("%s: camera device is already connected.", __FUNCTION__);

return NO_ERROR;

}

 

// open v4l2 camera device

int ret = openCameraDev(halInfo);

if (ret != OK)

{

         return ret;

}

 

//get sensor type form driver

switch((v4l2_sensor_type)getSensorType()){

case V4L2_SENSOR_TYPE_YUV:

LOGV("the sensor is YUV sensor");

mSensor_Type = V4L2_SENSOR_TYPE_YUV;

break;

case V4L2_SENSOR_TYPE_RAW:

LOGV("the sensor is RAW sensor");

mSensor_Type = V4L2_SENSOR_TYPE_RAW;

break;

default:

if(mIsUsbCamera) {

LOGV("the sensor is UVC sensor wyb add 2018/10/26 13:58");

mSensor_Type = V4L2_SENSOR_TYPE_YUV;

}

else {

LOGE("get the sensor type failed  wyb add 2018/10/26 14:59");

goto END_ERROR;

}

}

halInfo->fast_picture_mode = (int)mSensor_Type; //set the CameraHardware Class fast_picture_mode member

memcpy((void*)&mHalCameraInfo, (void*)halInfo, sizeof(HALCameraInfo));

 

……

 

return UNKNOWN_ERROR;

}

         

 

bool V4L2CameraDevice::captureThread()

{

……

//get picture flag

mTakePictureFlag.dwval = buf.reserved;

 

if (mLastZoom != mNewZoom)

{

float widthRate = (float)mFrameWidth / (float)mVideoWidth;

float heightRate = (float)mFrameHeight / (float)mVideoHeight;

if (mIsThumbUsedForVideo && (widthRate > 4.0) && (heightRate > 4.0))

{

calculateCrop(&mRectCrop, mNewZoom, mMaxZoom, mFrameWidth/2, mFrameHeight/2); // for cts, to do

}

else

{

// the main frame crop

calculateCrop(&mRectCrop, mNewZoom, mMaxZoom, mFrameWidth, mFrameHeight);

}

mCameraHardware->setNewCrop(&mRectCrop);

 

// the sub-frame crop

if (mHalCameraInfo.fast_picture_mode)

{

calculateCrop(&mThumbRectCrop, mNewZoom, mMaxZoom, mThumbWidth, mThumbHeight);

}

 

mLastZoom = mNewZoom;

mZoomRatio = (mNewZoom * 2 * 100 / mMaxZoom + 100);

LOGV("CROP: [%d, %d, %d, %d]", mRectCrop.left, mRectCrop.top, mRectCrop.right, mRectCrop.bottom);

LOGV("thumb CROP: [%d, %d, %d, %d]", mThumbRectCrop.left, mThumbRectCrop.top, mThumbRectCrop.right, mThumbRectCrop.bottom);

}

 

if (mVideoFormat != V4L2_PIX_FMT_YUYV

&& mCaptureFormat == V4L2_PIX_FMT_YUYV)

{

#ifdef USE_MP_CONVERT

YUYVToYUV420C((void*)buf.m.offset,

  (void*)(mVideoBuffer.buf_phy_addr[buf.index] | 0x40000000),

  mFrameWidth,

  mFrameHeight);

#else

if(mIsUsbCamera) {

YUYVToNV21(mMapMem.mem[buf.index],

   (void*)mVideoBuffer.buf_vir_addr[buf.index],

   mFrameWidth,

   mFrameHeight);

}

else

{

YUYVToNV12(mMapMem.mem[buf.index],

   (void*)mVideoBuffer.buf_vir_addr[buf.index],

   mFrameWidth,

   mFrameHeight);

}

#endif

}

 

// V4L2BUF_t for preview and HW encoder

V4L2BUF_t v4l2_buf;

if (mVideoFormat != V4L2_PIX_FMT_YUYV

&& mCaptureFormat == V4L2_PIX_FMT_YUYV)

{

v4l2_buf.addrPhyY = mVideoBuffer.buf_phy_addr[buf.index];

v4l2_buf.addrVirY = mVideoBuffer.buf_vir_addr[buf.index];

}

else

{

v4l2_buf.addrPhyY = buf.m.offset - BUFFER_PHY_OFFSET;

v4l2_buf.addrVirY = (unsigned int)mMapMem.mem[buf.index];

}

……

    return true;

}

 

 

(如果不修改这里,将会出现不能拍照的情况)

W:\r58_android_v4.4\android\device\softwinner\octopus-f1\configs\camera.cfg

;-------------------------------------------------------------------------------

; 用于camera的配置

;

; 采用格式:

; key = key_value

; 注意: 每个key需要顶格写;

; key_value紧跟着key后面的等号后面, 位于同一行中;

; key_value限制大小为256字节以内;

;

;-------------------------------------------------------------------------------

 

;-------------------------------------------------------------------------------

; exif information of "make" and "model"

;-------------------------------------------------------------------------------

key_camera_exif_make = MAKE_AllWinner

key_camera_exif_model = MODEL_f1

 

;-------------------------------------------------------------------------------

; 1 for single camera, 2 for double camera

;-------------------------------------------------------------------------------

number_of_camera = 1

 

;-------------------------------------------------------------------------------

; CAMERA_FACING_BACK

; ov8858

;-------------------------------------------------------------------------------

camera_id = 0

 

;-------------------------------------------------------------------------------

; 1 for CAMERA_FACING_FRONT

; 0 for CAMERA_FACING_BACK

;-------------------------------------------------------------------------------

camera_facing = 0

 

;-------------------------------------------------------------------------------

; 1 for camera without isp(using built-in isp of Axx)

; 0 for camera with isp

;-------------------------------------------------------------------------------

use_builtin_isp = 0

 

;-------------------------------------------------------------------------------

; camera orientation (0, 90, 180, 270)

;-------------------------------------------------------------------------------

camera_orientation = 90

 

;-------------------------------------------------------------------------------

; driver device name

;-------------------------------------------------------------------------------

camera_device = /dev/video0

 

;-------------------------------------------------------------------------------

; device id

; for two camera devices with one CSI

;-------------------------------------------------------------------------------

device_id = 0

 

used_preview_size = 1

key_support_preview_size = 640x480

key_default_preview_size = 640x480

 

used_picture_size = 1

key_support_picture_size = 640x480

key_default_picture_size = 640x480

 

used_flash_mode = 0

key_support_flash_mode = on,off,auto,red-eye,torch

key_default_flash_mode = off

 

used_color_effect=0

key_support_color_effect = none,mono,negative,sepia,aqua

key_default_color_effect = none

 

used_frame_rate = 1

key_support_frame_rate = 25

key_default_frame_rate = 25

 

used_focus_mode = 1

key_support_focus_mode = auto,infinity,macro,fixed

key_default_focus_mode = auto

 

;used_scene_mode = 0

;key_support_scene_mode = auto,action,portrait,landscape,night,night-portrait,theatre,beach,snow,sunset,steadyphoto,fireworks,sports,party,candlelight,barcode,hdr

;key_default_scene_mode = auto

 

used_scene_mode = 1

key_support_scene_mode = auto,hdr

key_default_scene_mode = auto

 

used_white_balance = 1

key_support_white_balance = auto,incandescent,fluorescent,warm-fluorescent,daylight,cloudy-daylight

key_default_white_balance = auto

 

used_exposure_compensation = 1

key_max_exposure_compensation = 3

key_min_exposure_compensation = -3

key_step_exposure_compensation = 1

key_default_exposure_compensation = 0

 

used_zoom = 1

key_zoom_supported = true

key_smooth_zoom_supported = false

key_zoom_ratios = 100,120,150,200,230,250,300

key_max_zoom = 30

key_default_zoom = 0

 

key_horizonal_view_angle = 64

key_vertical_view_angle = 39.4

 

 

(配置录像的格式,点录像会出错,原因未知!)

W:\r58_android_v4.4\android\device\softwinner\octopus-f1\configs\media_profiles.xml

 

 

W:\r58_android_v4.4\android\device\softwinner\octopus-f1\BoardConfig.mk

W:\r58_android_v4.4\android\device\softwinner\octopus-f1\init.sun8i.rc

#gpu

    insmod /system/vendor/modules/pvrsrvkm.ko

#    insmod /system/vendor/modules/dc_sunxi.ko

 

#csi module

    #insmod /system/vendor/modules/videobuf-core.ko

    #insmod /system/vendor/modules/videobuf-dma-contig.ko

    #insmod /system/vendor/modules/cci.ko

    #insmod /system/vendor/modules/actuator.ko

    #insmod /system/vendor/modules/vfe_os.ko

    #insmod /system/vendor/modules/vfe_subdev.ko

    #insmod /system/vendor/modules/dw9714_act.ko

    #insmod /system/vendor/modules/hi253.ko

    #insmod /system/vendor/modules/ov8858_4lane.ko

    #insmod /system/vendor/modules/vfe_v4l2.ko

 

# usb module / UVC

insmod /system/vendor/modules/videobuf2-core.ko

insmod /system/vendor/modules/videobuf2-memops.ko

insmod /system/vendor/modules/videobuf2-vmalloc.ko

insmod /system/vendor/modules/uvcvideo.ko

 

#facedetection module

    insmod /system/vendor/modules/sunxi_fd.ko

 

 

W:\r58_android_v4.4\android\device\softwinner\octopus-f1\octopus_f1.mk

 

 

打开USB摄像头驱动/UVC

W:\r58_android_v4.4\lichee\linux-3.4\.config

1、打印等级调整

rootroot@cm88:/home/wwt/r58_android_v4/lichee/linux-3.4$ make ARCH=arm menuconfig

Device Drivers  --->

<*> Multimedia support  --->

[*]   Video capture adapters  --->

[*]   V4L USB devices  --->

--- V4L USB devices

< >   USB Video Class (UVC)

修改为:

  USB Video Class (UVC)

 

[*]     UVC input events device support

 

 

 

W:\r58_android_v4.4\lichee\tools\pack\chips\sun8iw6p1\configs\f1\sys_config.fex

;--------------------------------------------------------------------------------

;vip (video input port) configuration

;vip_used: 0:disable 1:enable

;vip_mode: 0:sample one interface to one buffer 1:sample two interface to one buffer

;vip_dev_qty: The quantity of devices linked to capture bus

;

;vip_define_sensor_list: If you want use sensor detect function, please set vip_define_sensor_list = 1, and

;                                    verify that file /system/etc/hawkview/sensor_list_cfg.ini is properly configured!

;

;vip_dev(x)_pos: sensor position, "rear" or "front", if vip_define_sensor_list = 1,

;vip_dev(x)_pos must be configured!

;

;vip_dev(x)_isp_used 0:not use isp 1:use isp

;vip_dev(x)_fmt: 0:yuv 1:bayer raw rgb

;vip_dev(x)_stby_mode: 0:not shut down power at standby 1:shut down power at standby

;vip_dev(x)_vflip: flip in vertical direction 0:disable 1:enable

;vip_dev(x)_hflip: flip in horizontal direction 0:disable 1:enable

;vip_dev(x)_iovdd: camera module io power handle string, pmu power supply

;vip_dev(x)_iovdd_vol: camera module io power voltage, pmu power supply

;vip_dev(x)_avdd: camera module analog power handle string, pmu power supply

;vip_dev(x)_avdd_vol: camera module analog power voltage, pmu power supply

;vip_dev(x)_dvdd: camera module core power handle string, pmu power supply

;vip_dev(x)_dvdd_vol: camera module core power voltage, pmu power supply

;vip_dev(x)_afvdd: camera module vcm power handle string, pmu power supply

;vip_dev(x)_afvdd_vol: camera module vcm power voltage, pmu power supply

;x indicates the index of the devices which are linked to the same capture bus

;fill voltage in uV, e.g. iovdd = 2.8V, vip_devx_iovdd_vol = 2800000

;fill handle string as below:

;axp22_eldo3

;axp22_dldo4

;axp22_eldo2

;fill handle string "" when not using any pmu power supply

;--------------------------------------------------------------------------------

 

[csi0]

 

vip_used                 = 1

vip_mode                 = 0

vip_dev_qty              = 1

vip_define_sensor_list     = 0

 

;vip_csi_pck              = port:PE00<2>

vip_csi_mck              = port:PE01<2>

;vip_csi_hsync            = port:PE02<2>

;vip_csi_vsync            = port:PE03<2>

;vip_csi_d0               =

;vip_csi_d1               =

;vip_csi_d0               = port:PE04<2>

;vip_csi_d1               = port:PE05<2>

;vip_csi_d2               = port:PE06<2>

;vip_csi_d3               = port:PE07<2>

;vip_csi_d4               = port:PE08<2>

;vip_csi_d5               = port:PE09<2>

;vip_csi_d6               = port:PE10<2>

;vip_csi_d7               = port:PE11<2>

;vip_csi_d8               = port:PE12<2>

;vip_csi_d9               = port:PE13<2>

 

vip_csi_sck               = port:PE14<2>

vip_csi_sda               = port:PE15<2>

 

 

vip_dev0_mname           = "imx179"

vip_dev0_pos             = "rear"

vip_dev0_lane            = 4

vip_dev0_twi_id          = 0

vip_dev0_twi_addr        = 0x20

vip_dev0_isp_used        = 1

vip_dev0_fmt             = 1

vip_dev0_stby_mode       = 1

vip_dev0_vflip           = 1

vip_dev0_hflip           = 1

vip_dev0_iovdd           = "axp81x_dldo3"

vip_dev0_iovdd_vol       = 1800000

vip_dev0_avdd            = "axp81x_dldo4"

vip_dev0_avdd_vol        = 2700000

vip_dev0_dvdd            = "axp81x_eldo1"

vip_dev0_dvdd_vol        = 1200000

vip_dev0_afvdd           = "axp81x_dldo3"

vip_dev0_afvdd_vol       = 2800000

vip_dev0_power_en        =

vip_dev0_reset           = port:PE16<1>

vip_dev0_pwdn            = port:PE17<1>

vip_dev0_flash_en        =

vip_dev0_flash_mode      =

vip_dev0_af_pwdn         =

 

vip_dev0_act_used        = 1

vip_dev0_act_name        = "dw9714_act"

vip_dev0_act_slave       = 0x18

 

 

vip_dev1_mname           = "ov8865_4lane"

vip_dev1_pos             = "front"

vip_dev1_lane            = 4

vip_dev1_twi_id          = 0

vip_dev1_twi_addr        = 0x21

vip_dev1_isp_used        = 1

vip_dev1_fmt             = 1

vip_dev1_stby_mode       = 1

vip_dev1_vflip           = 0

vip_dev1_hflip           = 0

vip_dev1_iovdd           = "axp81x_dldo3"

vip_dev1_iovdd_vol       = 2800000

vip_dev1_avdd            = "axp81x_dldo4"

vip_dev1_avdd_vol        = 2800000

vip_dev1_dvdd            = "axp81x_eldo3"

vip_dev1_dvdd_vol        = 1200000

vip_dev1_afvdd           = "axp81x_dldo3"

vip_dev1_afvdd_vol       = 2800000

vip_dev1_power_en        =

vip_dev1_reset           = port:PB02<1>

vip_dev1_pwdn            = port:PB03<1>

vip_dev1_flash_en        =

vip_dev1_flash_mode      =

vip_dev1_af_pwdn         =

 

vip_dev1_act_used        = 1

vip_dev1_act_name        = "ad5820_act"

vip_dev1_act_slave       = 0x18

 

现阶段调出来的效果就是640x480分辨率拍照,其它拍照分辨率和录像正在尝试中!

 

转载于:https://www.cnblogs.com/wb4916/p/9922541.html

你可能感兴趣的:(31全志r58平台Android4.4.2下打开USB摄像头)