Commit 2f1361f8 authored by Depeng Shao's avatar Depeng Shao Committed by Hans Verkuil
Browse files

media: qcom: camss: csid: Only add TPG v4l2 ctrl if TPG hardware is available



There is no CSID TPG on some SoCs, so the v4l2 ctrl in CSID driver
shouldn't be registered. Checking the supported TPG modes to indicate
if the TPG hardware exists or not and only registering v4l2 ctrl for
CSID only when the TPG hardware is present.

Signed-off-by: default avatarDepeng Shao <quic_depengs@quicinc.com>
Signed-off-by: default avatarHans Verkuil <hverkuil@xs4all.nl>
parent 2f4204bb
Loading
Loading
Loading
Loading
+35 −25
Original line number Diff line number Diff line
@@ -760,12 +760,14 @@ static int csid_set_stream(struct v4l2_subdev *sd, int enable)
	int ret;

	if (enable) {
		if (csid->testgen.nmodes != CSID_PAYLOAD_MODE_DISABLED) {
			ret = v4l2_ctrl_handler_setup(&csid->ctrls);
			if (ret < 0) {
				dev_err(csid->camss->dev,
					"could not sync v4l2 controls: %d\n", ret);
				return ret;
			}
		}

		if (!csid->testgen.enabled &&
		    !media_pad_remote_pad_first(&csid->pads[MSM_CSID_PAD_SINK]))
@@ -838,7 +840,8 @@ static void csid_try_format(struct csid_device *csid,
		break;

	case MSM_CSID_PAD_SRC:
		if (csid->testgen_mode->cur.val == 0) {
		if (csid->testgen.nmodes == CSID_PAYLOAD_MODE_DISABLED ||
		    csid->testgen_mode->cur.val == 0) {
			/* Test generator is disabled, */
			/* keep pad formats in sync */
			u32 code = fmt->code;
@@ -888,7 +891,8 @@ static int csid_enum_mbus_code(struct v4l2_subdev *sd,

		code->code = csid->res->formats->formats[code->index].code;
	} else {
		if (csid->testgen_mode->cur.val == 0) {
		if (csid->testgen.nmodes == CSID_PAYLOAD_MODE_DISABLED ||
		    csid->testgen_mode->cur.val == 0) {
			struct v4l2_mbus_framefmt *sink_fmt;

			sink_fmt = __csid_get_format(csid, sd_state,
@@ -1267,7 +1271,8 @@ static int csid_link_setup(struct media_entity *entity,

		/* If test generator is enabled */
		/* do not allow a link from CSIPHY to CSID */
		if (csid->testgen_mode->cur.val != 0)
		if (csid->testgen.nmodes != CSID_PAYLOAD_MODE_DISABLED &&
		    csid->testgen_mode->cur.val != 0)
			return -EBUSY;

		sd = media_entity_to_v4l2_subdev(remote->entity);
@@ -1360,13 +1365,15 @@ int msm_csid_register_entity(struct csid_device *csid,
		 MSM_CSID_NAME, csid->id);
	v4l2_set_subdevdata(sd, csid);

	if (csid->testgen.nmodes != CSID_PAYLOAD_MODE_DISABLED) {
		ret = v4l2_ctrl_handler_init(&csid->ctrls, 1);
		if (ret < 0) {
			dev_err(dev, "Failed to init ctrl handler: %d\n", ret);
			return ret;
		}

	csid->testgen_mode = v4l2_ctrl_new_std_menu_items(&csid->ctrls,
		csid->testgen_mode =
			v4l2_ctrl_new_std_menu_items(&csid->ctrls,
						     &csid_ctrl_ops, V4L2_CID_TEST_PATTERN,
						     csid->testgen.nmodes, 0, 0,
						     csid->testgen.modes);
@@ -1378,6 +1385,7 @@ int msm_csid_register_entity(struct csid_device *csid,
		}

		csid->subdev.ctrl_handler = &csid->ctrls;
	}

	ret = csid_init_formats(sd, NULL);
	if (ret < 0) {
@@ -1408,6 +1416,7 @@ int msm_csid_register_entity(struct csid_device *csid,
media_cleanup:
	media_entity_cleanup(&sd->entity);
free_ctrl:
	if (csid->testgen.nmodes != CSID_PAYLOAD_MODE_DISABLED)
		v4l2_ctrl_handler_free(&csid->ctrls);

	return ret;
@@ -1421,6 +1430,7 @@ void msm_csid_unregister_entity(struct csid_device *csid)
{
	v4l2_device_unregister_subdev(&csid->subdev);
	media_entity_cleanup(&csid->subdev.entity);
	if (csid->testgen.nmodes != CSID_PAYLOAD_MODE_DISABLED)
		v4l2_ctrl_handler_free(&csid->ctrls);
}