#ifdef DEBUG
+static void debug_dump_generic_header(am7xxx_context *ctx, struct am7xxx_generic_header *g)
+{
+ if (ctx == NULL || g == NULL)
+ return;
+
+ debug(ctx, "Generic header:\n");
+ debug(ctx, "\tfield0: 0x%08x (%u)\n", g->field0, g->field0);
+ debug(ctx, "\tfield1: 0x%08x (%u)\n", g->field1, g->field1);
+ debug(ctx, "\tfield2: 0x%08x (%u)\n", g->field2, g->field2);
+ debug(ctx, "\tfield3: 0x%08x (%u)\n", g->field3, g->field3);
+}
+
static void debug_dump_devinfo_header(am7xxx_context *ctx, struct am7xxx_devinfo_header *d)
{
if (ctx == NULL || d == NULL)
break;
default:
- debug(ctx, "Packet type not supported!\n");
+ debug(ctx, "Parsing data not supported for this packet type!\n");
+ debug_dump_generic_header(ctx, &(h->header_data.data));
break;
}
debug(ctx, "END\n\n");
return ret;
}
+static int send_command(am7xxx_device *dev, am7xxx_packet_type type)
+{
+ struct am7xxx_header h = {
+ .packet_type = type,
+ .direction = AM7XXX_DIRECTION_OUT,
+ .header_data_len = 0x00,
+ .unknown2 = 0x3e,
+ .unknown3 = 0x10,
+ .header_data = {
+ .data = {
+ .field0 = 0,
+ .field1 = 0,
+ .field2 = 0,
+ .field3 = 0,
+ },
+ },
+ };
+
+ return send_header(dev, &h);
+}
+
+
/* When level == AM7XXX_LOG_FATAL do not check the log_level from the context
* and print the message unconditionally, this makes it possible to print
* fatal messages even early on initialization, before the context has been
am7xxx_device_info *device_info)
{
int ret;
- struct am7xxx_header h = {
- .packet_type = AM7XXX_PACKET_TYPE_DEVINFO,
- .direction = AM7XXX_DIRECTION_OUT,
- .header_data_len = 0x00,
- .unknown2 = 0x3e,
- .unknown3 = 0x10,
- .header_data = {
- .devinfo = {
- .native_width = 0,
- .native_height = 0,
- .unknown0 = 0,
- .unknown1 = 0,
- },
- },
- };
+ struct am7xxx_header h = { 0 };
if (dev->device_info) {
memcpy(device_info, dev->device_info, sizeof(*device_info));
return 0;
}
- ret = send_header(dev, &h);
+ ret = send_command(dev, AM7XXX_PACKET_TYPE_DEVINFO);
if (ret < 0)
return ret;