Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 4a2ccdd2 authored by Laurent Pinchart's avatar Laurent Pinchart Committed by Mauro Carvalho Chehab
Browse files

[media] adv7604: Cache register contents when reading multiple bits



When extracting multiple bits from a single register read the register
once and extract the bits on the read value.

Signed-off-by: default avatarLaurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: default avatarHans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: default avatarMauro Carvalho Chehab <m.chehab@samsung.com>
parent 51182a94
Loading
Loading
Loading
Loading
+20 −13
Original line number Original line Diff line number Diff line
@@ -1207,6 +1207,8 @@ static int stdi2dv_timings(struct v4l2_subdev *sd,


static int read_stdi(struct v4l2_subdev *sd, struct stdi_readback *stdi)
static int read_stdi(struct v4l2_subdev *sd, struct stdi_readback *stdi)
{
{
	u8 polarity;

	if (no_lock_stdi(sd) || no_lock_sspd(sd)) {
	if (no_lock_stdi(sd) || no_lock_sspd(sd)) {
		v4l2_dbg(2, debug, sd, "%s: STDI and/or SSPD not locked\n", __func__);
		v4l2_dbg(2, debug, sd, "%s: STDI and/or SSPD not locked\n", __func__);
		return -1;
		return -1;
@@ -1219,11 +1221,12 @@ static int read_stdi(struct v4l2_subdev *sd, struct stdi_readback *stdi)
	stdi->interlaced = io_read(sd, 0x12) & 0x10;
	stdi->interlaced = io_read(sd, 0x12) & 0x10;


	/* read SSPD */
	/* read SSPD */
	if ((cp_read(sd, 0xb5) & 0x03) == 0x01) {
	polarity = cp_read(sd, 0xb5);
		stdi->hs_pol = ((cp_read(sd, 0xb5) & 0x10) ?
	if ((polarity & 0x03) == 0x01) {
				((cp_read(sd, 0xb5) & 0x08) ? '+' : '-') : 'x');
		stdi->hs_pol = polarity & 0x10
		stdi->vs_pol = ((cp_read(sd, 0xb5) & 0x40) ?
			     ? (polarity & 0x08 ? '+' : '-') : 'x';
				((cp_read(sd, 0xb5) & 0x20) ? '+' : '-') : 'x');
		stdi->vs_pol = polarity & 0x40
			     ? (polarity & 0x20 ? '+' : '-') : 'x';
	} else {
	} else {
		stdi->hs_pol = 'x';
		stdi->hs_pol = 'x';
		stdi->vs_pol = 'x';
		stdi->vs_pol = 'x';
@@ -1881,6 +1884,8 @@ static int adv7604_log_status(struct v4l2_subdev *sd)
	struct v4l2_dv_timings timings;
	struct v4l2_dv_timings timings;
	struct stdi_readback stdi;
	struct stdi_readback stdi;
	u8 reg_io_0x02 = io_read(sd, 0x02);
	u8 reg_io_0x02 = io_read(sd, 0x02);
	u8 edid_enabled;
	u8 cable_det;


	static const char * const csc_coeff_sel_rb[16] = {
	static const char * const csc_coeff_sel_rb[16] = {
		"bypassed", "YPbPr601 -> RGB", "reserved", "YPbPr709 -> RGB",
		"bypassed", "YPbPr601 -> RGB", "reserved", "YPbPr709 -> RGB",
@@ -1910,20 +1915,22 @@ static int adv7604_log_status(struct v4l2_subdev *sd)


	v4l2_info(sd, "-----Chip status-----\n");
	v4l2_info(sd, "-----Chip status-----\n");
	v4l2_info(sd, "Chip power: %s\n", no_power(sd) ? "off" : "on");
	v4l2_info(sd, "Chip power: %s\n", no_power(sd) ? "off" : "on");
	edid_enabled = rep_read(sd, 0x7d);
	v4l2_info(sd, "EDID enabled port A: %s, B: %s, C: %s, D: %s\n",
	v4l2_info(sd, "EDID enabled port A: %s, B: %s, C: %s, D: %s\n",
			((rep_read(sd, 0x7d) & 0x01) ? "Yes" : "No"),
			((edid_enabled & 0x01) ? "Yes" : "No"),
			((rep_read(sd, 0x7d) & 0x02) ? "Yes" : "No"),
			((edid_enabled & 0x02) ? "Yes" : "No"),
			((rep_read(sd, 0x7d) & 0x04) ? "Yes" : "No"),
			((edid_enabled & 0x04) ? "Yes" : "No"),
			((rep_read(sd, 0x7d) & 0x08) ? "Yes" : "No"));
			((edid_enabled & 0x08) ? "Yes" : "No"));
	v4l2_info(sd, "CEC: %s\n", !!(cec_read(sd, 0x2a) & 0x01) ?
	v4l2_info(sd, "CEC: %s\n", !!(cec_read(sd, 0x2a) & 0x01) ?
			"enabled" : "disabled");
			"enabled" : "disabled");


	v4l2_info(sd, "-----Signal status-----\n");
	v4l2_info(sd, "-----Signal status-----\n");
	cable_det = io_read(sd, 0x6f);
	v4l2_info(sd, "Cable detected (+5V power) port A: %s, B: %s, C: %s, D: %s\n",
	v4l2_info(sd, "Cable detected (+5V power) port A: %s, B: %s, C: %s, D: %s\n",
			((io_read(sd, 0x6f) & 0x10) ? "Yes" : "No"),
			((cable_det & 0x10) ? "Yes" : "No"),
			((io_read(sd, 0x6f) & 0x08) ? "Yes" : "No"),
			((cable_det & 0x08) ? "Yes" : "No"),
			((io_read(sd, 0x6f) & 0x04) ? "Yes" : "No"),
			((cable_det & 0x04) ? "Yes" : "No"),
			((io_read(sd, 0x6f) & 0x02) ? "Yes" : "No"));
			((cable_det & 0x02) ? "Yes" : "No"));
	v4l2_info(sd, "TMDS signal detected: %s\n",
	v4l2_info(sd, "TMDS signal detected: %s\n",
			no_signal_tmds(sd) ? "false" : "true");
			no_signal_tmds(sd) ? "false" : "true");
	v4l2_info(sd, "TMDS signal locked: %s\n",
	v4l2_info(sd, "TMDS signal locked: %s\n",