我是靠谱客的博主 洁净凉面,最近开发中收集的这篇文章主要介绍Mtk平台Camera Sensor添加mipi_pixel_rate属性,觉得挺不错的,现在分享给大家,希望可以做个参考。

概述

(1)添加原因

在使用Camera的时候Log中总出现如下相关Error:

12-25 15:11:09.606250   749 17060 E MtkCam/HalSensor: [sendCommand] SENSOR_CMD_GET_SENSOR_PIXELMODE: mipi pixel rate should not be 0 (sendCommand){#628:vendor/mediatek/proprietary/hardware/mtkcam/drv/src/sensor/mt6761/../common/v1/HalSensor.control.cpp}
12-25 15:11:09.606288   749 17060 E MtkCam/HalSensor: [sendCommand] CMD_SENSOR_GET_PIXEL_RATE: pixel rate should not be 0 (sendCommand){#632:vendor/mediatek/proprietary/hardware/mtkcam/drv/src/sensor/mt6761/../common/v1/HalSensor.control.cpp}
12-25 15:11:09.606310   749 17060 E SeninfDrvImp: [getPixelMode]Err( 3662):pixel rate should not be zero (getPixelMode){#3662:vendor/mediatek/proprietary/hardware/mtkcam/drv/src/sensor/mt6761/seninf_drv.cpp}

由报错可知,是由于Hal Sensor没有配置mipi_pixel_rate属性导致,接下来简单配置一下。

(2)Camera Sensor配置

static imgsensor_info_struct imgsensor_info = {
	.sensor_id = S5K5E2YA_SENSOR_ID,

	.checksum_value = 0xa48ebf5d,

	.pre = {
		.pclk = 179200000,				//record different mode's pclk
		.linelength = 2950,				//record different mode's linelength
		.framelength = 2000,			//record different mode's framelength
		.startx = 0,					//record different mode's startx of grabwindow
		.starty = 0,					//record different mode's starty of grabwindow
		.grabwindow_width = 1280,		//record different mode's width of grabwindow
		.grabwindow_height = 960,		//record different mode's height of grabwindow
		/*	 following for MIPIDataLowPwr2HighSpeedSettleDelayCount by different scenario	*/
		.mipi_data_lp2hs_settle_dc = 23,
		/*	 following for GetDefaultFramerateByScenario()	*/
		.mipi_pixel_rate = 177800000,
		.max_framerate = 300,
	},
	.cap = {
		.pclk = 179200000,
		.linelength = 2950,
		.framelength = 2025,
		.startx = 0,
		.starty = 0,
		.grabwindow_width = 2560,
		.grabwindow_height = 1920,
		.mipi_data_lp2hs_settle_dc = 23,
		.mipi_pixel_rate = 179600000,
		.max_framerate = 300,
	},
	.cap1 = {
		.pclk = 87200000,
		.linelength = 2950,
		.framelength = 1970,
		.startx = 0,
		.starty = 0,
		.grabwindow_width = 2560,
		.grabwindow_height = 1920,
		.mipi_data_lp2hs_settle_dc = 23,
		.mipi_pixel_rate = 179600000,
		.max_framerate = 150,
	},
	.normal_video = {
		.pclk = 179200000,
		.linelength = 2950,
		.framelength = 2000,
		.startx = 0,
		.starty = 0,
		.grabwindow_width = 2560,
		.grabwindow_height = 1440,
		.mipi_data_lp2hs_settle_dc = 23,
		.mipi_pixel_rate = 177400000,
		.max_framerate = 300,
	},
	.hs_video = {
		.pclk = 179200000,
		.linelength = 2950,
		.framelength = 506,
		.startx = 0,
		.starty = 0,
		.grabwindow_width = 640,
		.grabwindow_height = 480,
		.mipi_data_lp2hs_settle_dc = 23,
		.mipi_pixel_rate = 180900000,
		.max_framerate = 1200,
	},
	.slim_video = {
		.pclk = 179200000,
		.linelength = 2950,
		.framelength = 2000,
		.startx = 0,
		.starty = 0,
		.grabwindow_width = 1280,
		.grabwindow_height = 720,
		.mipi_data_lp2hs_settle_dc = 23,
		.mipi_pixel_rate = 177800000,
		.max_framerate = 300,
	},
	.margin = 4,
	.min_shutter = 1,
	.max_frame_length = 0xffff,
	.ae_shut_delay_frame = 0,
	.ae_sensor_gain_delay_frame = 1,
	.ae_ispGain_delay_frame = 2,
	.ihdr_support = 0,	  //1, support; 0,not support
	.ihdr_le_firstline = 0,  //1,le first ; 0, se first
	.sensor_mode_num = 5,	  //support sensor mode num

	.cap_delay_frame = 3,
	.pre_delay_frame = 3,
	.video_delay_frame = 3,
	.hs_video_delay_frame = 3,
	.slim_video_delay_frame = 3,

	.isp_driving_current = ISP_DRIVING_6MA,
	.sensor_interface_type = SENSOR_INTERFACE_TYPE_MIPI,
	.mipi_sensor_type = MIPI_OPHY_NCSI2, //0,MIPI_OPHY_NCSI2;  1,MIPI_OPHY_CSI2
	.mipi_settle_delay_mode = MIPI_SETTLEDELAY_AUTO,//0,MIPI_SETTLEDELAY_AUTO; 1,MIPI_SETTLEDELAY_MANNUAL
	.sensor_output_dataformat = SENSOR_OUTPUT_FORMAT_RAW_Gb,
	.mclk = 24,
	.mipi_lane_num = SENSOR_MIPI_2_LANE,
	.i2c_addr_table = {0x20, 0x6c, 0xff},
};

在每个mode中都需要配置mipi_pixel_rate属性,同时在feature_control当中也需要添加如下。

static kal_uint32 feature_control(MSDK_SENSOR_FEATURE_ENUM feature_id,
							 UINT8 *feature_para,UINT32 *feature_para_len)
{
//...
//add start
case SENSOR_FEATURE_GET_MIPI_PIXEL_RATE:
	{
		switch (*feature_data) {
		case MSDK_SCENARIO_ID_CAMERA_CAPTURE_JPEG:
			*(MUINT32 *)(uintptr_t)(*(feature_data + 1)) =
				imgsensor_info.cap.mipi_pixel_rate;
			break;
		case MSDK_SCENARIO_ID_VIDEO_PREVIEW:
			*(MUINT32 *)(uintptr_t)(*(feature_data + 1)) =
				imgsensor_info.normal_video.mipi_pixel_rate;
			break;
		case MSDK_SCENARIO_ID_HIGH_SPEED_VIDEO:
			*(MUINT32 *)(uintptr_t)(*(feature_data + 1)) =
				imgsensor_info.hs_video.mipi_pixel_rate;
			break;
		case MSDK_SCENARIO_ID_SLIM_VIDEO:
			*(MUINT32 *)(uintptr_t)(*(feature_data + 1)) =
				imgsensor_info.slim_video.mipi_pixel_rate;
			break;
		case MSDK_SCENARIO_ID_CAMERA_PREVIEW:
		default:
			*(MUINT32 *)(uintptr_t)(*(feature_data + 1)) =
				imgsensor_info.pre.mipi_pixel_rate;
			break;
		}
	}
	break;

	/*only for Android R (Android 11)/ISP 5.0
	delete SENSOR_FEATURE_GET_PIXEL_RATE in Android Q (Android 10) & earlier versions*/
	case SENSOR_FEATURE_GET_PIXEL_RATE:
		switch (*feature_data) {
		case MSDK_SCENARIO_ID_CAMERA_CAPTURE_JPEG:
			*(MUINT32 *)(uintptr_t)(*(feature_data + 1)) =
			(imgsensor_info.cap.pclk /
			(imgsensor_info.cap.linelength - 80))*
			imgsensor_info.cap.grabwindow_width;
			break;
		case MSDK_SCENARIO_ID_VIDEO_PREVIEW:
			*(MUINT32 *)(uintptr_t)(*(feature_data + 1)) =
			(imgsensor_info.normal_video.pclk /
			(imgsensor_info.normal_video.linelength - 80))*
			imgsensor_info.normal_video.grabwindow_width;
			break;
		case MSDK_SCENARIO_ID_HIGH_SPEED_VIDEO:
			*(MUINT32 *)(uintptr_t)(*(feature_data + 1)) =
			(imgsensor_info.hs_video.pclk /
			(imgsensor_info.hs_video.linelength - 80))*
			imgsensor_info.hs_video.grabwindow_width;
			break;
		case MSDK_SCENARIO_ID_SLIM_VIDEO:
			*(MUINT32 *)(uintptr_t)(*(feature_data + 1)) =
			(imgsensor_info.slim_video.pclk /
			(imgsensor_info.slim_video.linelength - 80))*
			imgsensor_info.slim_video.grabwindow_width;
			break;
		case MSDK_SCENARIO_ID_CAMERA_PREVIEW:
		default:
			*(MUINT32 *)(uintptr_t)(*(feature_data + 1)) =
			(imgsensor_info.pre.pclk /
			(imgsensor_info.pre.linelength - 80))*
			imgsensor_info.pre.grabwindow_width;
			break;
		}
		break;
//add end
//...
}

(3)如何计算mipi_pixel_rate值

 计算sensor的mipi_pixel_rate值:
 
adb shell sentest arg1 arg2

//arg1: 指定sensor
main sensor (arg1 = 1)
sub sensor (arg1 = 2)

//arg2:指定sensor mode
preview (arg2 = 0)
capture (arg2 = 1)
video (arg2 = 2)
hs video (arg2 = 3)
slim video (arg2 = 4)

(4)sensor的fps计算值

fps = pclk/linelength/framelength

(5)FOV值计算

CTS FOV:FOCAL_LENGTH =  WIDTH_PIXEL_SIZE  / (2 * tan FOV / 2)

(6)copy tuning和metadata文件如何快速改名

比如将hi552_mipi_raw的tuning效果和metadata文件copy一份给到s5k5e2ya_mipi_raw来使用,可按照如下操作步骤实施。

//(1) 将当前目录及子目录下,文件名含有"xxx1"的字符全部替换为"xxx2"
rename  -v  's/xxx1/xxx2/'  `find ./ -name "*xxx1*"`
//eg
tct_title.xml替换后为:wt_title.xml

//(2)将当前目录及子目录下,文件内容含有"xxx1"的字符全部替换为"xxx2",且排除搜索.git目录
sed -i  "s/xxx1/xxx2/g"  `grep "xxx1" -rl ./ -R --exclude-dir=.git`

//(3)不需要排除.git目录
sed -i  "s/xxx1/xxx2/g"  `grep "xxx1" -rl ./`
  • 先copy一份hi552_mipi_raw的文件夹出来,并将其重命名为s5k5e2ya_mipi_raw;
  • 进入该文件夹后,执行
rename  -v  's/hi552/s5k5e2ya/'  `find ./ -name "*hi552*"`
sed -i  "s/hi552/s5k5e2ya/g"  `grep "hi552" -rl ./`
sed -i  "s/HI552/S5K5E2YA/g"  `grep "HI552" -rl ./`

如上执行完成后,文件即可完全改名,可尝试全编译。

最后

以上就是洁净凉面为你收集整理的Mtk平台Camera Sensor添加mipi_pixel_rate属性的全部内容,希望文章能够帮你解决Mtk平台Camera Sensor添加mipi_pixel_rate属性所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(53)

评论列表共有 0 条评论

立即
投稿
返回
顶部