X-Git-Url: https://git.ao2.it/libam7xxx.git/blobdiff_plain/20fde3f474e27dd334f836e3c9d12aafae72140b..759559da7fb9c03e5f42eab12acbc01ebe763186:/src/am7xxx.c diff --git a/src/am7xxx.c b/src/am7xxx.c index 405d141..76b997c 100644 --- a/src/am7xxx.c +++ b/src/am7xxx.c @@ -228,6 +228,18 @@ struct am7xxx_header { #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) @@ -306,7 +318,8 @@ static void debug_dump_header(am7xxx_context *ctx, struct am7xxx_header *h) 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"); @@ -573,6 +586,28 @@ static int send_header(am7xxx_device *dev, struct am7xxx_header *h) 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 @@ -1025,28 +1060,14 @@ AM7XXX_PUBLIC int am7xxx_get_device_info(am7xxx_device *dev, 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;