由於公司買的板子,供應商nb轟轟不給開源,自己拿着老掉牙的Android源碼一點點添加功能,以下就是添加hdmiin功能辛酸淚記錄史。
(1)hdmiin接口使用tc358749芯片轉換。
添加tc358749驅動源碼,firefly官網上Android系統源碼已經開源,可以在裏面找到tc358749.c/tc358749.h源碼,在/kernel/driver/media/video/rk_camsys/路徑下。
驅動添加好之後,修改設備樹文件,找到板子配套dts文件,我這個是rk3288-tb_8846.dts。
由於hdminin數據走i2c通道,所以把tc358749節點掛在i2c上,套路了供應商是i2c4通道。下面就是配置引腳,引腳配置需要根據電路圖設計,而拿不到電路圖的我在完好的板子上,利用“cat sys/kernel/debug/gpio”命令找到hdmiin成功申請gpio引腳。最終配置如下:
tc358749@0f {
compatible = "rockchip,tc359849";
reg = <0x0f>;
gpio-power = <&gpio7 GPIO_C5 GPIO_ACTIVE_HIGH>;
gpio-stanby = <&gpio7 GPIO_A4 GPIO_ACTIVE_HIGH>;
gpio-reset = <&gpio8 GPIO_B0 GPIO_ACTIVE_HIGH>;
gpio-int = <&gpio8 GPIO_A7 GPIO_ACTIVE_HIGH>;
status = "okay";
};
經啓動hdmiin應用程序,dmesg命令記錄,測試設備樹和驅動文件連接成功,驅動成功完成探測函數。
(2)此時,hdmiin應用程序打開,閃退。
經“adb wait-for-usb-device shell dmesg”命令,打印開機內核log。
發現出現“iommu status not consistent,check the dts file!”錯誤,經檢查源碼,發現vpu節點iommu未使能,打開rk3288.dtsi設備樹文件,修改vpu節點iommu參數。
(3)此時,打開hdmiin應用程序,顯示黑屏。
因爲hdmiin做成一個camera接口,所以經過hal層。經“adb shell logcat”命令打印Android系統開機log,發現有多個camera設備。如下:
D/CameraHal( 188): ParserSensorInfo(46): SensorName(OV5648)
D/CameraHal( 188): ParserSensorInfo(46): SensorName(OV2659)
D/CameraHal( 188): ParserSensorInfo(46): SensorName(GS8604)
D/CameraHal( 188): ParserSensorInfo(46): SensorName(IMX214)
D/CameraHal( 188): ParserSensorInfo(46): SensorName(TC358749XBG)等等。。。
找到/hardware/rockchip/camera/Config/下cam_board_rk3288.xml文件,除TC358749XBG外camera設備全部屏蔽掉。
並且根據電路板設計修改tc358749的sensor參數:
<CamDevie>
<HardWareInfo>
<Sensor>
<SensorName name="TC358749XBG" ></SensorName>
<SensorDevID IDname="CAMSYS_DEVID_SENSOR_1A"></SensorDevID> //id name
<SensorHostDevID busnum="CAMSYS_DEVID_MARVIN" ></SensorHostDevID>
<SensorI2cBusNum busnum="4"></SensorI2cBusNum> //i2c通道
<SensorI2cAddrByte byte="2"></SensorI2cAddrByte> //i2c地址長度
<SensorI2cRate rate="100000"></SensorI2cRate>
<SensorMclk mclk="27000000"></SensorMclk>
<SensorAvdd name="NC" min="0" max="0"></SensorAvdd>
<SensorDovdd name="NC" min="18000000" max="18000000"></SensorDovdd>
<SensorDvdd name="NC" min="0" max="0"></SensorDvdd>
<SensorGpioPwdn ioname="NC" active="0"></SensorGpioPwdn>
<SensorGpioRst ioname="NC" active="0"></SensorGpioRst>
<SensorGpioPwen ioname="NC" active="1"></SensorGpioPwen>
<SensorFacing facing="back"></SensorFacing>
<SensorInterface interface="MIPI"></SensorInterface>
<SensorMirrorFlip mirror="0"></SensorMirrorFlip>
<SensorOrientation orientation="0"></SensorOrientation>
<SensorPowerupSequence seq="1234"></SensorPowerupSequence>
<SensorFovParemeter h="60.0" v="60.0"></SensorFovParemeter>
<SensorAWB_Frame_Skip fps="0"></SensorAWB_Frame_Skip>
<SensorPhy phyMode="CamSys_Phy_Mipi" lane="4" phyIndex="0" sensorFmt="CamSys_Fmt_Yuv422_8b">
</SensorPhy> //mipi通道
</Sensor>
<VCM>
<VCMDrvName name="NC"></VCMDrvName>
<VCMName name="NC"></VCMName>
<VCMI2cBusNum busnum="0"></VCMI2cBusNum>
<VCMI2cAddrByte byte="0"></VCMI2cAddrByte>
<VCMI2cRate rate="0"></VCMI2cRate>
<VCMVdd name="NC" min="0" max="0"></VCMVdd>
<VCMGpioPwdn ioname="NC" active="0"></VCMGpioPwdn>
<VCMGpioPower ioname="NC" active="0"></VCMGpioPower>
<VCMCurrent start="0" rated="100" vcmmax="100" stepmode="4" drivermax="100"></VCMCurrent>
</VCM>
<Flash>
<FlashName name="NC"></FlashName>
<FlashI2cBusNum busnum="0"></FlashI2cBusNum>
<FlashI2cAddrByte byte="0"></FlashI2cAddrByte>
<FlashI2cRate rate="0"></FlashI2cRate>
<FlashTrigger ioname="NC" active="0"></FlashTrigger>
<FlashEn ioname="NC" active="0"></FlashEn>
<FlashModeType mode="1"></FlashModeType>
<FlashLuminance luminance="0"></FlashLuminance>
<FlashColorTemp colortemp="0"></FlashColorTemp>
</Flash>
</HardWareInfo>
<SoftWareInfo>
<AWB>
<AWB_Auto support="0"></AWB_Auto>
<AWB_Incandescent support="0"></AWB_Incandescent>
<AWB_Fluorescent support="0"></AWB_Fluorescent>
<AWB_Warm_Fluorescent support="0"></AWB_Warm_Fluorescent>
<AWB_Daylight support="0"></AWB_Daylight>
<AWB_Cloudy_Daylight support="0"></AWB_Cloudy_Daylight>
<AWB_Twilight support="0"></AWB_Twilight>
<AWB_Shade support="0"></AWB_Shade>
</AWB>
<Sence>
<Sence_Mode_Auto support="0"></Sence_Mode_Auto>
<Sence_Mode_Action support="0"></Sence_Mode_Action>
<Sence_Mode_Portrait support="0"></Sence_Mode_Portrait>
<Sence_Mode_Landscape support="0"></Sence_Mode_Landscape>
<Sence_Mode_Night support="0"></Sence_Mode_Night>
<Sence_Mode_Night_Portrait support="0"></Sence_Mode_Night_Portrait>
<Sence_Mode_Theatre support="0"></Sence_Mode_Theatre>
<Sence_Mode_Beach support="0"></Sence_Mode_Beach>
<Sence_Mode_Snow support="0"></Sence_Mode_Snow>
<Sence_Mode_Sunset support="0"></Sence_Mode_Sunset>
<Sence_Mode_Steayphoto support="0"></Sence_Mode_Steayphoto>
<Sence_Mode_Pireworks support="0"></Sence_Mode_Pireworks>
<Sence_Mode_Sports support="0"></Sence_Mode_Sports>
<Sence_Mode_Party support="0"></Sence_Mode_Party>
<Sence_Mode_Candlelight support="0"></Sence_Mode_Candlelight>
<Sence_Mode_Barcode support="0"></Sence_Mode_Barcode>
<Sence_Mode_HDR support="0"></Sence_Mode_HDR>
</Sence>
<Effect>
<Effect_None support="1"></Effect_None>
<Effect_Mono support="0"></Effect_Mono>
<Effect_Solarize support="0"></Effect_Solarize>
<Effect_Negative support="0"></Effect_Negative>
<Effect_Sepia support="0"></Effect_Sepia>
<Effect_Posterize support="0"></Effect_Posterize>
<Effect_Whiteboard support="0"></Effect_Whiteboard>
<Effect_Blackboard support="0"></Effect_Blackboard>
<Effect_Aqua support="0"></Effect_Aqua>
</Effect>
<FocusMode>
<Focus_Mode_Auto support="0"></Focus_Mode_Auto>
<Focus_Mode_Infinity support="0"></Focus_Mode_Infinity>
<Focus_Mode_Marco support="0"></Focus_Mode_Marco>
<Focus_Mode_Fixed support="0"></Focus_Mode_Fixed>
<Focus_Mode_Edof support="0"></Focus_Mode_Edof>
<Focus_Mode_Continuous_Video support="0"></Focus_Mode_Continuous_Video>
<Focus_Mode_Continuous_Picture support="0"></Focus_Mode_Continuous_Picture>
</FocusMode>
<FlashMode>
<Flash_Mode_Off support="0"></Flash_Mode_Off>
<Flash_Mode_On support="0"></Flash_Mode_On>
<Flash_Mode_Torch support="0"></Flash_Mode_Torch>
<Flash_Mode_Auto support="0"></Flash_Mode_Auto>
<Flash_Mode_Red_Eye support="0"></Flash_Mode_Red_Eye>
</FlashMode>
<AntiBanding>
<Anti_Banding_Auto support="0"></Anti_Banding_Auto>
<Anti_Banding_50HZ support="0"></Anti_Banding_50HZ>
<Anti_Banding_60HZ support="0"></Anti_Banding_60HZ>
<Anti_Banding_Off support="0"></Anti_Banding_Off>
</AntiBanding>
<HDR support="0"></HDR>
<ZSL support="0"></ZSL>
<DigitalZoom support="1"></DigitalZoom>
<Continue_SnapShot support="1"></Continue_SnapShot>
<InterpolationRes resolution="0"></InterpolationRes>
<PreviewSize width="1280" height="720"></PreviewSize>
<FaceDetect support="0" MaxNum="0"></FaceDetect>
<Cproc support="0" contrast="1.1" saturation="1.8" hue="0" brightness="0"></Cproc>
<Gammaout support = "0" gamma = "0.5" offset = "0"></Gammaout>
<DV>
<DV_QCIF name="qcif" width="176" height="144" fps="30" support="0"></DV_QCIF>
<DV_QVGA name="qvga" width="320" height="240" fps="30" support="0"></DV_QVGA>
<DV_CIF name="cif" width="352" height="288" fps="30" support="0"></DV_CIF>
<DV_VGA name="480p" width="640" height="480" fps="30" support="0"></DV_VGA>
<DV_480P name="480p" width="720" height="480" fps="30" support="0"></DV_480P>
<DV_720P name="720p" width="1280" height="720" fps="60" support="1"></DV_720P>
<DV_1080P name="1080p" width="1920" height="1080" fps="60" support="1"></DV_1080P>
</DV>
</SoftWareInfo>
</CamDevie>
(4)到這裏,hdmiin還是黑屏。
hal源碼也大概看了看,沒什麼問題,檢查了一下rk封裝的isp動態庫文件,發現老源碼裏面的比較小
用開源源碼的庫文件替換了自己老的的libisp_silicomimageisp_api.so文件,這時hdmiin應用順利打開了。
本人在以往的經歷,對Android源碼涉足不深,好吧,沒有涉及過。第一次在底層添加此類應用,還望大家多多指教,感謝能夠提出更好的見解,以待學習。