Skip to contentSkip to conversation

pulse8-cec: fixes

PATCH In review Johan Fjeldtvedt 2 participants 3 messages Aug 30, 2016 – Sep 5, 2016

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/2 pulse8-cec: fixes

Fix some small things:
- clean up setup function
- use MSGEND instead of 0xfe
- don't assign "return value" from cec_phys_addr to err, it has return type void.

---
 drivers/staging/media/pulse8-cec/pulse8-cec.c | 33 ++++++++-------------------
 1 file changed, 10 insertions(+), 23 deletions(-)
drivers/staging/media/pulse8-cec/pulse8-cec.c +10 -23
index 193f4d1..1158ba9 100644
@@ -266,7 +266,7 @@ static int pulse8_send(struct serio *serio, const u8 *command, u8 cmd_len)
 		}
 	}
 	if (!err)
-		err = serio_write(serio, 0xfe);
+		err = serio_write(serio, MSGEND);
 
 	return err;
 }
@@ -331,40 +331,29 @@ static int pulse8_setup(struct pulse8 *pulse8, struct serio *serio,
 	u8 *data = pulse8->data + 1;
 	u8 cmd[2];
 	int err;
+	struct tm tm;
+	time_t date;
 
 	pulse8->vers = 0;
 
-	cmd[0] = MSGCODE_PING;
-	err = pulse8_send_and_wait(pulse8, cmd, 1,
-				   MSGCODE_COMMAND_ACCEPTED, 0);
 	cmd[0] = MSGCODE_FIRMWARE_VERSION;
-	if (!err)
-		err = pulse8_send_and_wait(pulse8, cmd, 1, cmd[0], 2);
+	err = pulse8_send_and_wait(pulse8, cmd, 1, cmd[0], 2);
 	if (err)
 		return err;
-
 	pulse8->vers = (data[0] << 8) | data[1];
-
 	dev_info(pulse8->dev, "Firmware version %04x\n", pulse8->vers);
 	if (pulse8->vers < 2)
 		return 0;
 
 	cmd[0] = MSGCODE_GET_BUILDDATE;
-	if (!err)
-		err = pulse8_send_and_wait(pulse8, cmd, 1, cmd[0], 4);
-	if (!err) {
-		time_t date = (data[0] << 24) | (data[1] << 16) |
-			(data[2] << 8) | data[3];
-		struct tm tm;
-
-		time_to_tm(date, 0, &tm);
-
-		dev_info(pulse8->dev, "Firmware build date %04ld.%02d.%02d %02d:%02d:%02d\n",
-			 tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday,
-			 tm.tm_hour, tm.tm_min, tm.tm_sec);
-	}
+	err = pulse8_send_and_wait(pulse8, cmd, 1, cmd[0], 4);
 	if (err)
 		return err;
+	date = (data[0] << 24) | (data[1] << 16) | (data[2] << 8) | data[3];
+	time_to_tm(date, 0, &tm);
+	dev_info(pulse8->dev, "Firmware build date %04ld.%02d.%02d %02d:%02d:%02d\n",
+		 tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday,
+		 tm.tm_hour, tm.tm_min, tm.tm_sec);
 
 	dev_dbg(pulse8->dev, "Persistent config:\n");
 	cmd[0] = MSGCODE_GET_AUTO_ENABLED;
@@ -456,8 +445,6 @@ static int pulse8_apply_persistent_config(struct pulse8 *pulse8,
 		return err;
 
 	cec_s_phys_addr(pulse8->adap, pa, false);
-	if (err)
-		return err;
 
 	return 0;
 }
Signature · 1 line
2.9.3
#1 lore raw

PATCH 2/2 pulse8-cec: store logical address mask

In addition to setting the ACK mask, also set the logical address mask setting in the dongle. This is (and not the ACK mask) is persisted for use in autonomous mode.

The logical address mask to use is deduced from the primary device type in adap->log_addrs.

---
 drivers/staging/media/pulse8-cec/pulse8-cec.c | 34 +++++++++++++++++++++++++++
 1 file changed, 34 insertions(+)
drivers/staging/media/pulse8-cec/pulse8-cec.c +34 -0
index 1158ba9..ede285a 100644
@@ -498,6 +498,40 @@ static int pulse8_cec_adap_log_addr(struct cec_adapter *adap, u8 log_addr)
 	if (err)
 		goto unlock;
 
+	switch (adap->log_addrs.primary_device_type[0]) {
+	case CEC_OP_PRIM_DEVTYPE_TV:
+		mask = 0;
+		break;
+	case CEC_OP_PRIM_DEVTYPE_RECORD:
+		mask = 0x206;
+		break;
+	case CEC_OP_PRIM_DEVTYPE_TUNER:
+		mask = 0x4C8;
+		break;
+	case CEC_OP_PRIM_DEVTYPE_PLAYBACK:
+		mask = 0x910;
+		break;
+	case CEC_OP_PRIM_DEVTYPE_AUDIOSYSTEM:
+		mask = 0x20;
+		break;
+	case CEC_OP_PRIM_DEVTYPE_SWITCH:
+		mask = 0x8000;
+		break;
+	case CEC_OP_PRIM_DEVTYPE_PROCESSOR:
+		mask = 0x4000;
+		break;
+	default:
+		mask = 0;
+		break;
+	}
+	cmd[0] = MSGCODE_SET_LOGICAL_ADDRESS_MASK;
+	cmd[1] = mask >> 8;
+	cmd[2] = mask & 0xff;
+	err = pulse8_send_and_wait(pulse8, cmd, 3,
+				   MSGCODE_COMMAND_ACCEPTED, 0);
+	if (err)
+		goto unlock;
+
 	cmd[0] = MSGCODE_SET_DEFAULT_LOGICAL_ADDRESS;
 	cmd[1] = log_addr;
 	err = pulse8_send_and_wait(pulse8, cmd, 2,
Signature · 1 line
2.9.3
#2 lore raw

Re: [PATCH 2/2] pulse8-cec: store logical address mask

Quoted 17 lines · Johan Fjeldtvedt

In addition to setting the ACK mask, also set the logical address mask setting in the dongle. This is (and not the ACK mask) is persisted for use in autonomous mode.

The logical address mask to use is deduced from the primary device type in adap->log_addrs.

---
 drivers/staging/media/pulse8-cec/pulse8-cec.c | 34 +++++++++++++++++++++++++++
 1 file changed, 34 insertions(+)
drivers/staging/media/pulse8-cec/pulse8-cec.c +0 -0
index 1158ba9..ede285a 100644

drivers/staging/media/pulse8-cec/pulse8-cec.c static int pulse8_cec_adap_log_addr(struct cec_adapter *adap, u8 log_addr) · line 503

Quoted 6 lines
drivers/staging/media/pulse8-cec/pulse8-cec.c +3 -0
@@ -498,6 +498,40 @@ static int pulse8_cec_adap_log_addr(struct cec_adapter *adap, u8 log_addr)
 	if (err)
 		goto unlock;
 
+	switch (adap->log_addrs.primary_device_type[0]) {
+	case CEC_OP_PRIM_DEVTYPE_TV:
+		mask = 0;

Is this right? Shouldn't it be 0x001?

drivers/staging/media/pulse8-cec/pulse8-cec.c static int pulse8_cec_adap_log_addr(struct cec_adapter *adap, u8 log_addr) · line 506

Quoted 3 lines
drivers/staging/media/pulse8-cec/pulse8-cec.c +3 -0
+		break;
+	case CEC_OP_PRIM_DEVTYPE_RECORD:
+		mask = 0x206;

Note that cec.h has CEC_LOG_ADDR_MASK_ defines. It's better to use those.

Regards,

Hans

Quoted 32 lines
drivers/staging/media/pulse8-cec/pulse8-cec.c +28 -0
+		break;
+	case CEC_OP_PRIM_DEVTYPE_TUNER:
+		mask = 0x4C8;
+		break;
+	case CEC_OP_PRIM_DEVTYPE_PLAYBACK:
+		mask = 0x910;
+		break;
+	case CEC_OP_PRIM_DEVTYPE_AUDIOSYSTEM:
+		mask = 0x20;
+		break;
+	case CEC_OP_PRIM_DEVTYPE_SWITCH:
+		mask = 0x8000;
+		break;
+	case CEC_OP_PRIM_DEVTYPE_PROCESSOR:
+		mask = 0x4000;
+		break;
+	default:
+		mask = 0;
+		break;
+	}
+	cmd[0] = MSGCODE_SET_LOGICAL_ADDRESS_MASK;
+	cmd[1] = mask >> 8;
+	cmd[2] = mask & 0xff;
+	err = pulse8_send_and_wait(pulse8, cmd, 3,
+				   MSGCODE_COMMAND_ACCEPTED, 0);
+	if (err)
+		goto unlock;
+
 	cmd[0] = MSGCODE_SET_DEFAULT_LOGICAL_ADDRESS;
 	cmd[1] = log_addr;
 	err = pulse8_send_and_wait(pulse8, cmd, 2,