ShaneCCC, thanks a lot for your help!
2. Try to make the below function to a dummy function to try both v4l2-ctl and gstreamer.
ok, now my driver source looks like this:
static int ar0132_set_gain(struct ar0132_priv *priv, s32 val)
{
return 0;
}
static int ar0132_set_frame_length(struct ar0132_priv *priv, s32 val)
{
u32 frame_length;
frame_length = (u32)val;
priv->frame_length = frame_length;
return 0;
}
static int ar0132_set_coarse_time(struct ar0132_priv *priv, s32 val)
{
return 0;
}
static int ar0132_set_coarse_time_short(struct ar0132_priv *priv, s32 val)
{
int err;
struct v4l2_control hdr_control;
int hdr_en;
u32 coarse_time_short;
hdr_control.id = V4L2_CID_HDR_EN;
err = camera_common_g_ctrl(priv->s_data, &hdr_control);
if (err < 0) {
dev_err(&priv->i2c_client->dev,
"could not find device ctrl.\n");
return err;
}
hdr_en = switch_ctrl_qmenu[hdr_control.value];
if (hdr_en == SWITCH_OFF)
return 0;
coarse_time_short = (u32)val;
return 0;
}
static const struct v4l2_ctrl_config ctrl_config_list[] = {
{
.ops = &ar0132_ctrl_ops,
.id = V4L2_CID_HDR_EN,
.name = "HDR enable",
.type = V4L2_CTRL_TYPE_INTEGER_MENU,
.min = 0,
.max = ARRAY_SIZE(switch_ctrl_qmenu) - 1,
.menu_skip_mask = 0,
.def = 0,
.qmenu_int = switch_ctrl_qmenu,
},
{
.ops = &ar0132_ctrl_ops,
.id = V4L2_CID_GAIN,
.name = "Gain",
.type = V4L2_CTRL_TYPE_INTEGER64,
.flags = V4L2_CTRL_FLAG_SLIDER,
.min = 0 * FIXED_POINT_SCALING_FACTOR,
.max = 48 * FIXED_POINT_SCALING_FACTOR,
.def = 0 * FIXED_POINT_SCALING_FACTOR,
.step = 1 * FIXED_POINT_SCALING_FACTOR,
},
{
.ops = &ar0132_ctrl_ops,
.id = V4L2_CID_FRAME_LENGTH,
.name = "Frame Length",
.type = V4L2_CTRL_TYPE_INTEGER,
.flags = V4L2_CTRL_FLAG_SLIDER,
.min = OV5693_MIN_FRAME_LENGTH, // i use defines from OV5693
.max = OV5693_MAX_FRAME_LENGTH,
.def = OV5693_DEFAULT_FRAME_LENGTH,
.step = 1,
},
{
.ops = &ar0132_ctrl_ops,
.id = V4L2_CID_COARSE_TIME,
.name = "Coarse Time",
.type = V4L2_CTRL_TYPE_INTEGER,
.flags = V4L2_CTRL_FLAG_SLIDER,
.min = OV5693_MIN_EXPOSURE_COARSE,
.max = OV5693_MAX_EXPOSURE_COARSE,
.def = OV5693_DEFAULT_EXPOSURE_COARSE,
.step = 1,
},
{
.ops = &ar0132_ctrl_ops,
.id = V4L2_CID_COARSE_TIME_SHORT,
.name = "Coarse Time Short",
.type = V4L2_CTRL_TYPE_INTEGER,
.flags = V4L2_CTRL_FLAG_SLIDER,
.min = OV5693_MIN_EXPOSURE_COARSE,
.max = OV5693_MAX_EXPOSURE_COARSE,
.def = OV5693_DEFAULT_EXPOSURE_COARSE,
.step = 1,
},
{
.ops = &ar0132_ctrl_ops,
.id = V4L2_CID_GROUP_HOLD,
.name = "Group Hold",
.type = V4L2_CTRL_TYPE_INTEGER_MENU,
.min = 0,
.max = ARRAY_SIZE(switch_ctrl_qmenu) - 1,
.menu_skip_mask = 0,
.def = 0,
.qmenu_int = switch_ctrl_qmenu,
},
};
static int ar0132_s_ctrl(struct v4l2_ctrl *ctrl)
{
struct ar0132_priv *priv = container_of(ctrl->handler, struct ar0132_priv , ctrl_handler);
struct i2c_client *client = priv->i2c_client;
int ret = 0;
int data = 0;
//int state;
dev_err(&client->dev, "ar0132_s_ctrl with ctrl 0x%04X\n", ctrl->id);
switch (ctrl->id) {
case V4L2_CID_GAIN:
ret = ar0132_set_gain(priv, ctrl->val);
// ...
break;
case V4L2_CID_FRAME_LENGTH:
ret = ar0132_set_frame_length(priv, ctrl->val);
break;
case V4L2_CID_COARSE_TIME:
ret = ar0132_set_coarse_time(priv, ctrl->val);
break;
case V4L2_CID_COARSE_TIME_SHORT:
ret = ar0132_set_coarse_time_short(priv, ctrl->val);
break;
case V4L2_CID_FRAME_RATE:
break;
case V4L2_CID_GROUP_HOLD:
if (switch_ctrl_qmenu[ctrl->val] == SWITCH_ON) {
priv->group_hold_en = true;
} else {
priv->group_hold_en = false;
ret = ar0132_set_group_hold(priv);
}
break;
case V4L2_CID_HDR_EN:
break;
default:
goto out;
}
out:
dev_err(&client->dev, "ar0132_s_ctrl return %d\n", ret);
return ret;
}
when i start gst-launch in dmesg:
[ 616.419027] [ar0132] ar0132_set_autoexposure ret=0
[ 616.435243] ar0132 6-0010: [ar0132]: write i2c-dev:0x10 addr:0x3070= 0x0 - OK
[ 616.442865] ar0132 6-0010: ret: 00
[ 616.496579] ar0132 6-0010: ar0132_s_ctrl with ctrl 0x9A2003
[ 616.502502] ar0132 6-0010: ar0132_s_ctrl return 0
[ 616.507314] ar0132 6-0010: ar0132_s_ctrl with ctrl 0x9A200B
[ 616.513052] ar0132 6-0010: ar0132_s_ctrl return 0
[ 616.517797] ar0132 6-0010: ar0132_s_ctrl with ctrl 0x9A200C
[ 616.523439] ar0132 6-0010: ar0132_s_ctrl return 0
[ 616.528185] ar0132 6-0010: ar0132_s_ctrl with ctrl 0x9A2003
[ 616.533797] ar0132 6-0010: ar0132_s_ctrl return 0
[ 619.029622] tegra-i2c 7000d000.i2c: pio xfer timed out addr: 0x3c
[ 619.035716] tegra-i2c 7000d000.i2c: --- register dump for debugging ----
[ 619.042457] tegra-i2c 7000d000.i2c: I2C_CNFG - 0x22c00
[ 619.047595] tegra-i2c 7000d000.i2c: I2C_PACKET_TRANSFER_STATUS - 0x1010001
[ 619.054465] tegra-i2c 7000d000.i2c: I2C_FIFO_CONTROL - 0xe0
[ 619.060031] tegra-i2c 7000d000.i2c: I2C_FIFO_STATUS - 0x800081
[ 619.065857] tegra-i2c 7000d000.i2c: I2C_INT_MASK - 0x7d
[ 619.071075] tegra-i2c 7000d000.i2c: I2C_INT_STATUS - 0xc3
[ 619.076472] tegra-i2c 7000d000.i2c: i2c transfer timed out addr: 0x3c
[ 619.082940] max77620-gpio max77620-gpio: CNFG_GPIOx read failed: -110
[ 621.085638] tegra-i2c 7000d000.i2c: pio xfer timed out addr: 0x3c
[ 621.091729] tegra-i2c 7000d000.i2c: --- register dump for debugging ----
[ 621.098460] tegra-i2c 7000d000.i2c: I2C_CNFG - 0x22c00
[ 621.103615] tegra-i2c 7000d000.i2c: I2C_PACKET_TRANSFER_STATUS - 0x1010001
[ 621.110505] tegra-i2c 7000d000.i2c: I2C_FIFO_CONTROL - 0xe0
[ 621.116090] tegra-i2c 7000d000.i2c: I2C_FIFO_STATUS - 0x800081
[ 621.121934] tegra-i2c 7000d000.i2c: I2C_INT_MASK - 0x7d
[ 621.127171] tegra-i2c 7000d000.i2c: I2C_INT_STATUS - 0xc3
[ 621.132588] tegra-i2c 7000d000.i2c: i2c transfer timed out addr: 0x3c
[ 621.139071] max77620-gpio max77620-gpio: CNFG_GPIOx read failed: -110
[ 623.145656] tegra-i2c 7000d000.i2c: pio xfer timed out addr: 0x3c
[ 623.151750] tegra-i2c 7000d000.i2c: --- register dump for debugging ----
[ 623.158484] tegra-i2c 7000d000.i2c: I2C_CNFG - 0x22c00
[ 623.163642] tegra-i2c 7000d000.i2c: I2C_PACKET_TRANSFER_STATUS - 0x1010001
[ 623.170531] tegra-i2c 7000d000.i2c: I2C_FIFO_CONTROL - 0xe0
[ 623.176115] tegra-i2c 7000d000.i2c: I2C_FIFO_STATUS - 0x800081
[ 623.181959] tegra-i2c 7000d000.i2c: I2C_INT_MASK - 0x7d
[ 623.187248] tegra-i2c 7000d000.i2c: I2C_INT_STATUS - 0xc3
[ 623.192664] tegra-i2c 7000d000.i2c: i2c transfer timed out addr: 0x3c
[ 623.199150] max77620-gpio max77620-gpio: CNFG_GPIO_OUT update failed: -110
[ 626.561699] mmc0: Timeout waiting for hardware interrupt.
[ 626.567089] sdhci: =========== REGISTER DUMP (mmc0)===========
[ 626.572908] sdhci: Sys addr: 0x000000c0 | Version: 0x00000303
[ 626.578727] sdhci: Blk size: 0x00007200 | Blk cnt: 0x00000000
[ 626.584545] sdhci: Argument: 0x00000003 | Trn mode: 0x00000023
[ 626.590363] sdhci: Present: 0x01fb00f0 | Host ctl: 0x00000034
[ 626.596181] sdhci: Power: 0x00000001 | Blk gap: 0x00000000
[ 626.601999] sdhci: Wake-up: 0x00000000 | Clock: 0x00000007
[ 626.607817] sdhci: Timeout: 0x0000000e | Int stat: 0x00000003
[ 626.613635] sdhci: Int enab: 0x02ff000b | Sig enab: 0x02fc000b
[ 626.619452] sdhci: AC12 err: 0x00000000 | Slot int: 0x00000000
[ 626.625270] sdhci: Caps: 0x376cd08c | Caps_1: 0x10006f73
[ 626.631087] sdhci: Cmd: 0x0000261b | Max curr: 0x00000000
[ 626.636904] sdhci: Host ctl2: 0x0000300d
[ 626.640816] sdhci: ADMA Err: 0x00000000 | ADMA Ptr: 0x0000000080000020
[ 626.647326] sdhci: ===========================================
[ 626.653178] host1x 50000000.host1x: cdma_handle_timeout: timeout: 28 (54080000.vi_0) client 7, HW thresh 0, done 1
[ 626.663526] mmc_erase: erase error -110, status 0x0
[ 626.668404] blk_update_request: I/O error, dev mmcblk0, sector 8126498
[ 626.674962] host1x 50000000.host1x: cdma_handle_timeout: timeout: 42 (54080000.vi_4) client 7, HW thresh 1, done 1
[ 626.685300] host1x 50000000.host1x: cdma_handle_timeout: timeout: 39 (54080000.vi_2) client 7, HW thresh 1, done 1
[ 626.695638] ---- mlocks ----
[ 626.698527]
[ 626.700011] ---- syncpts ----
[ 626.702980] id 1 (disp1_a) min 1118 max 1118 refs 1 (previous client : )
[ 626.709676] id 2 (disp1_b) min 2 max 2 refs 1 (previous client : )
[ 626.715852] id 3 (disp1_c) min 2 max 2 refs 1 (previous client : )
[ 626.722025] id 4 (57000000.gpu_507) min 15608 max 15608 refs 1 (previous client : )
[ 626.729674] id 5 (57000000.gpu_506) min 34 max 34 refs 1 (previous client : )
[ 626.736804] id 6 (57000000.gpu_505) min 8220 max 8220 refs 1 (previous client : 57000000.gpu_505)
[ 626.745665] id 7 (54600000.isp_0) min 0 max 3 refs 4 (previous client : )
[ 626.752446] id 8 (54600000.isp_1) min 0 max 3 refs 4 (previous client : )
[ 626.759230] id 9 (54600000.isp_2) min 7 max 16 refs 11 (previous client : )
[ 626.766185] id 11 (54600000.isp_3) min 1 max 3 refs 4 (previous client : )
[ 626.773055] id 16 (57000000.gpu_504) min 1222 max 1222 refs 1 (previous client : )
[ 626.780618] id 17 (57000000.gpu_503) min 2 max 2 refs 1 (previous client : )
[ 626.787658] id 18 (57000000.gpu_502) min 2 max 2 refs 1 (previous client : )
[ 626.794698] id 19 (57000000.gpu_501) min 2 max 2 refs 1 (previous client : )
[ 626.801740] id 20 (57000000.gpu_500) min 2 max 2 refs 1 (previous client : )
[ 626.808779] id 21 (57000000.gpu_499) min 8 max 8 refs 1 (previous client : )
[ 626.815822] id 22 (57000000.gpu_491) min 6 max 6 refs 1 (previous client : 54080000.vi_0)
[ 626.823992] id 23 (57000000.gpu_490) min 6 max 6 refs 1 (previous client : 54080000.vi_1)
[ 626.832160] id 24 (57000000.gpu_489) min 7 max 7 refs 1 (previous client : 54080000.vi_2)
[ 626.840328] id 25 (57000000.gpu_488) min 6 max 6 refs 1 (previous client : 54080000.vi_5)
[ 626.848498] id 27 (vblank1) min 22907 max 0 refs 1 (previous client : )
[ 626.855105] id 28 (54080000.vi_0) min 0 max 3 refs 4 (previous client : 54080000.vi_3)
[ 626.863015] id 32 (57000000.gpu_498) min 1060 max 1060 refs 1 (previous client : )
[ 626.870578] id 33 (57000000.gpu_497) min 2 max 2 refs 1 (previous client : )
[ 626.877619] id 34 (57000000.gpu_496) min 2 max 2 refs 1 (previous client : )
[ 626.884660] id 35 (57000000.gpu_495) min 2 max 2 refs 1 (previous client : )
[ 626.891702] id 36 (57000000.gpu_494) min 2 max 2 refs 1 (previous client : )
[ 626.898743] id 37 (57000000.gpu_492) min 4 max 4 refs 1 (previous client : )
when i start v4l-compliance:
nvidia@tegra-ubuntu:~$ v4l2-compliance
Driver Info:
Driver name : tegra-video
Card type : vi-output, ar0132 6-0010
Bus info : platform:54080000.vi:2
Driver version: 4.4.38
Capabilities : 0x84200001
Video Capture
Streaming
Extended Pix Format
Device Capabilities
Device Caps : 0x04200001
Video Capture
Streaming
Extended Pix Format
Compliance test for device /dev/video0 (not using libv4l2):
Required ioctls:
test VIDIOC_QUERYCAP: OK
Allow for multiple opens:
test second video open: OK
test VIDIOC_QUERYCAP: OK
test VIDIOC_G/S_PRIORITY: OK
Debug ioctls:
test VIDIOC_DBG_G/S_REGISTER: OK
test VIDIOC_LOG_STATUS: OK
Input ioctls:
test VIDIOC_G/S_TUNER/ENUM_FREQ_BANDS: OK (Not Supported)
test VIDIOC_G/S_FREQUENCY: OK (Not Supported)
test VIDIOC_S_HW_FREQ_SEEK: OK (Not Supported)
test VIDIOC_ENUMAUDIO: OK (Not Supported)
test VIDIOC_G/S/ENUMINPUT: OK
test VIDIOC_G/S_AUDIO: OK (Not Supported)
Inputs: 1 Audio Inputs: 0 Tuners: 0
Output ioctls:
test VIDIOC_G/S_MODULATOR: OK (Not Supported)
test VIDIOC_G/S_FREQUENCY: OK (Not Supported)
test VIDIOC_ENUMAUDOUT: OK (Not Supported)
test VIDIOC_G/S/ENUMOUTPUT: OK (Not Supported)
test VIDIOC_G/S_AUDOUT: OK (Not Supported)
Outputs: 0 Audio Outputs: 0 Modulators: 0
Input/Output configuration ioctls:
test VIDIOC_ENUM/G/S/QUERY_STD: OK (Not Supported)
test VIDIOC_ENUM/G/S/QUERY_DV_TIMINGS: OK (Not Supported)
test VIDIOC_DV_TIMINGS_CAP: OK (Not Supported)
test VIDIOC_G/S_EDID: OK (Not Supported)
Test input 0:
Control ioctls:
test VIDIOC_QUERY_EXT_CTRL/QUERYMENU: OK
test VIDIOC_QUERYCTRL: OK
test VIDIOC_G/S_CTRL: OK
test VIDIOC_G/S/TRY_EXT_CTRLS: OK
test VIDIOC_(UN)SUBSCRIBE_EVENT/DQEVENT: OK
test VIDIOC_G/S_JPEGCOMP: OK (Not Supported)
Standard Controls: 4 Private Controls: 10
Format ioctls:
test VIDIOC_ENUM_FMT/FRAMESIZES/FRAMEINTERVALS: OK
test VIDIOC_G/S_PARM: OK (Not Supported)
test VIDIOC_G_FBUF: OK (Not Supported)
test VIDIOC_G_FMT: OK
test VIDIOC_TRY_FMT: OK
test VIDIOC_S_FMT: OK
test VIDIOC_G_SLICED_VBI_CAP: OK (Not Supported)
test Cropping: OK (Not Supported)
test Composing: OK (Not Supported)
test Scaling: OK (Not Supported)
Codec ioctls:
test VIDIOC_(TRY_)ENCODER_CMD: OK (Not Supported)
test VIDIOC_G_ENC_INDEX: OK (Not Supported)
test VIDIOC_(TRY_)DECODER_CMD: OK (Not Supported)
Buffer ioctls:
test VIDIOC_REQBUFS/CREATE_BUFS/QUERYBUF: OK
test VIDIOC_EXPBUF: OK
Test input 0:
Total: 42, Succeeded: 42, Failed: 0, Warnings: 0
[ 619.029622] tegra-i2c 7000d000.i2c: pio xfer timed out addr: 0x3c - it looks like my driver broke another i2c interface?