From: Antonio Ospite Date: Tue, 17 Nov 2015 15:39:40 +0000 (+0100) Subject: Merge tag 'v0.1.6' into debian X-Git-Tag: debian/0.1.6-1~4 X-Git-Url: https://git.ao2.it/libam7xxx.git/commitdiff_plain/439fda96691ad4b51e435ef8bb1ae495511fc1b4?hp=e297ee41ce818e90149f352f40a1b2faf2cbecca Merge tag 'v0.1.6' into debian Release version 0.1.6 --- diff --git a/NEWS b/NEWS index e23a882..4b63b2d 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,25 @@ +News for v0.1.6: +================ + + * Fix some ffmpeg compile time deprecation warnings in am7xxx-play + * Fix some fmmpeg runtime warnings + * Don't dump the last frame unconditionally in am7xxx-play when in DEBUG + mode, add an option to enable the frame dump, but this is only active in + DEBUG mode + * Fix some compilation warnings from clang + * Replace deprecated FFmpeg API symbol PIX_FMT_NV12 in am7xx-play (Thanks to + Andreas Cadhalpun) + * Fix the Length field in the switch command in am7xxx-modeswitch (Thanks to + Balasubramanian S) + * More robust handling of USB configurations + * More robust handling of kernel driver detachment (Thanks to Andrea + Console) + * Minor documentation cleanups + * Minor build system improvements (am7xxx-play can now build without XCB, + but some functionalities will not be available) + * Misc code cleanups + * Relicense the example under GPL-3+ + News for v0.1.5: ================ diff --git a/TODO b/TODO index 1ce3068..46bf8de 100644 --- a/TODO +++ b/TODO @@ -4,3 +4,8 @@ (this may not be necessary if the GStreamer sink works well enough). - If there will ever be an API breakage, consider using more portable types (e.g. off_t for file sizes, size_t for counters, etc.) +- uniform the style of if() checks in cmake files +- evaluate the use of error() instead of debug() for error paths +- make the switch_command in am7xxx-modeswitch more readable using the + explicit bulk_cb_wrap structure from include/linux/usb/storage.h in the + linux kernel. diff --git a/contrib/am7xxx-play-window.sh b/contrib/am7xxx-play-window.sh index 2978ef2..dd8703d 100755 --- a/contrib/am7xxx-play-window.sh +++ b/contrib/am7xxx-play-window.sh @@ -13,13 +13,13 @@ set -e DISPLAY=":0" - + WIN_INFO="$(xwininfo)" - + X=$(echo "$WIN_INFO" | sed -n -e "/^[[:space:]]*Absolute upper-left X:[[:space:]]*/s///p") Y=$(echo "$WIN_INFO" | sed -n -e "/^[[:space:]]*Absolute upper-left Y:[[:space:]]*/s///p") WIDTH=$(echo "$WIN_INFO" | sed -n -e "/^[[:space:]]*Width:[[:space:]]*/s///p") HEIGHT=$(echo "$WIN_INFO" | sed -n -e "/^[[:space:]]*Height:[[:space:]]*/s///p") - + set -x am7xxx-play -f x11grab -i "${DISPLAY}+${X},${Y}" -o video_size="${WIDTH}x${HEIGHT}" diff --git a/contrib/performance/0001-Instrument-code-with-fps-meter.patch b/contrib/performance/0001-Instrument-code-with-fps-meter.patch index 5c133ee..ef81acb 100644 --- a/contrib/performance/0001-Instrument-code-with-fps-meter.patch +++ b/contrib/performance/0001-Instrument-code-with-fps-meter.patch @@ -1,6 +1,6 @@ -From dc6b216ffea1e80fd3f43d6144eb679a193f5666 Mon Sep 17 00:00:00 2001 -From: Antonio Ospite -Date: Sun, 28 Jul 2013 01:06:41 +0200 +From ab3f910957638300224f1f114df6e73115ec86b7 Mon Sep 17 00:00:00 2001 +From: Antonio Ospite +Date: Tue, 17 Nov 2015 16:28:03 +0100 Subject: [PATCH] Instrument code with fps-meter X-Face: z*RaLf`X<@C75u6Ig9}{oW$H;1_\2t5)({*|jhM/Vb;]yA5 +#include #include #include @@ -28,53 +29,85 @@ static unsigned char switch_command[] = "\x55\x53\x42\x43\x08\x70\x52\x89\x00\x00\x00\x00\x00\x00" - "\x0c\xff\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"; + "\x10\xff\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"; int main(void) { int ret; - int transferred; - libusb_device_handle *usb_device = NULL; - + libusb_device_handle *usb_device; + int current_configuration; unsigned int len; + int transferred; ret = libusb_init(NULL); - if (ret < 0) + if (ret < 0) { + fprintf(stderr, "libusb_init failed: %s\n", + libusb_error_name(ret)); goto out; + } - libusb_set_debug(NULL, 3); + libusb_set_debug(NULL, LIBUSB_LOG_LEVEL_INFO); usb_device = libusb_open_device_with_vid_pid(NULL, AM7XXX_STORAGE_VID, AM7XXX_STORAGE_PID); if (usb_device == NULL) { - fprintf(stderr, "cannot open the device: %d.\n", errno); + fprintf(stderr, "libusb_open failed: %s\n", strerror(errno)); ret = -errno; goto out; } - if (libusb_kernel_driver_active(usb_device, AM7XXX_STORAGE_INTERFACE)) { - ret = libusb_detach_kernel_driver(usb_device, - AM7XXX_STORAGE_INTERFACE); - if (ret < 0) - fprintf(stderr, "Warning: cannot detach kernel driver.\n"); - } else { - fprintf(stderr, "kernel driver not active.\n"); - } - - ret = libusb_set_configuration(usb_device, AM7XXX_STORAGE_CONFIGURATION); + current_configuration = -1; + ret = libusb_get_configuration(usb_device, ¤t_configuration); if (ret < 0) { - fprintf(stderr, "cannot set configuration.\n"); + fprintf(stderr, "libusb_get_configuration failed: %s\n", + libusb_error_name(ret)); goto out_libusb_close; } + if (current_configuration != AM7XXX_STORAGE_CONFIGURATION) { + ret = libusb_set_configuration(usb_device, + AM7XXX_STORAGE_CONFIGURATION); + if (ret < 0) { + fprintf(stderr, "libusb_set_configuration failed: %s\n", + libusb_error_name(ret)); + fprintf(stderr, "Cannot set configuration %d\n", + AM7XXX_STORAGE_CONFIGURATION); + goto out_libusb_close; + } + } + + libusb_set_auto_detach_kernel_driver(usb_device, 1); + ret = libusb_claim_interface(usb_device, AM7XXX_STORAGE_INTERFACE); if (ret < 0) { - fprintf(stderr, "cannot claim interface.\n"); + fprintf(stderr, "libusb_claim_interface failed: %s\n", + libusb_error_name(ret)); + fprintf(stderr, "Cannot claim interface %d\n", + AM7XXX_STORAGE_INTERFACE); goto out_libusb_close; } + /* Checking that the configuration has not changed, as suggested in + * http://libusb.sourceforge.net/api-1.0/caveats.html + */ + current_configuration = -1; + ret = libusb_get_configuration(usb_device, ¤t_configuration); + if (ret < 0) { + fprintf(stderr, "libusb_get_configuration after claim failed: %s\n", + libusb_error_name(ret)); + goto out_libusb_release_interface; + } + + if (current_configuration != AM7XXX_STORAGE_CONFIGURATION) { + fprintf(stderr, "libusb configuration changed (expected: %d, current: %d\n", + AM7XXX_STORAGE_CONFIGURATION, current_configuration); + ret = -EINVAL; + goto out_libusb_release_interface; + } + len = sizeof(switch_command); + transferred = 0; ret = libusb_bulk_transfer(usb_device, AM7XXX_STORAGE_OUT_EP, switch_command, len, &transferred, 0); diff --git a/examples/am7xxx-play.c b/examples/am7xxx-play.c index 2fa615a..6b0d206 100644 --- a/examples/am7xxx-play.c +++ b/examples/am7xxx-play.c @@ -216,7 +216,7 @@ static int video_output_init(struct video_output_ctx *output_ctx, */ if (image_format == AM7XXX_IMAGE_FORMAT_NV12) { fprintf(stdout, "using raw output format\n"); - output_codec_ctx->pix_fmt = PIX_FMT_NV12; + output_codec_ctx->pix_fmt = AV_PIX_FMT_NV12; output_ctx->codec_ctx = output_codec_ctx; output_ctx->raw_output = 1; ret = 0; @@ -235,8 +235,8 @@ static int video_output_init(struct video_output_ctx *output_ctx, * in particular they won't be 0, this is needed because they are used * as divisor somewhere in the encoding process */ output_codec_ctx->qmin = output_codec_ctx->qmax = ((100 - (quality - 1)) * FF_QUALITY_SCALE) / 100; - output_codec_ctx->mb_lmin = output_codec_ctx->lmin = output_codec_ctx->qmin * FF_QP2LAMBDA; - output_codec_ctx->mb_lmax = output_codec_ctx->lmax = output_codec_ctx->qmax * FF_QP2LAMBDA; + output_codec_ctx->mb_lmin = output_codec_ctx->qmin * FF_QP2LAMBDA; + output_codec_ctx->mb_lmax = output_codec_ctx->qmax * FF_QP2LAMBDA; output_codec_ctx->flags |= CODEC_FLAG_QSCALE; output_codec_ctx->global_quality = output_codec_ctx->qmin * FF_QP2LAMBDA; @@ -276,7 +276,8 @@ static int am7xxx_play(const char *input_format_string, unsigned int upscale, unsigned int quality, am7xxx_image_format image_format, - am7xxx_device *dev) + am7xxx_device *dev, + int dump_frame) { struct video_input_ctx input_ctx; struct video_output_ctx output_ctx; @@ -320,6 +321,9 @@ static int am7xxx_play(const char *input_format_string, ret = -ENOMEM; goto cleanup_picture_raw; } + picture_scaled->format = (output_ctx.codec_ctx)->pix_fmt; + picture_scaled->width = (output_ctx.codec_ctx)->width; + picture_scaled->height = (output_ctx.codec_ctx)->height; /* calculate the bytes needed for the output image and create buffer for the output image */ out_buf_size = avpicture_get_size((output_ctx.codec_ctx)->pix_fmt, @@ -354,6 +358,7 @@ static int am7xxx_play(const char *input_format_string, goto cleanup_out_buf; } + got_packet = 0; while (run) { /* read packet */ ret = av_read_frame(input_ctx.format_ctx, &in_packet); @@ -381,11 +386,11 @@ static int am7xxx_play(const char *input_format_string, goto end_while; } - /* if we get the complete frame */ + /* if we got the complete frame */ if (got_picture) { /* convert it to YUV */ sws_scale(sw_scale_ctx, - (const uint8_t * const*)picture_raw->data, + (const uint8_t * const *)picture_raw->data, picture_raw->linesize, 0, (input_ctx.codec_ctx)->height, @@ -416,15 +421,19 @@ static int am7xxx_play(const char *input_format_string, } #ifdef DEBUG - char filename[NAME_MAX]; - FILE *file; - if (!output_ctx.raw_output) - snprintf(filename, NAME_MAX, "out_q%03d.jpg", quality); - else - snprintf(filename, NAME_MAX, "out.raw"); - file = fopen(filename, "wb"); - fwrite(out_picture, 1, out_picture_size, file); - fclose(file); + if (dump_frame) { + char filename[NAME_MAX]; + FILE *file; + if (!output_ctx.raw_output) + snprintf(filename, NAME_MAX, "out_q%03d.jpg", quality); + else + snprintf(filename, NAME_MAX, "out.raw"); + file = fopen(filename, "wb"); + fwrite(out_picture, 1, out_picture_size, file); + fclose(file); + } +#else + (void) dump_frame; #endif ret = am7xxx_send_image_async(dev, @@ -434,7 +443,7 @@ static int am7xxx_play(const char *input_format_string, out_picture, out_picture_size); if (ret < 0) { - perror("am7xxx_send_image"); + perror("am7xxx_send_image_async"); run = 0; goto end_while; } @@ -593,6 +602,9 @@ static void usage(char *name) printf("usage: %s [OPTIONS]\n\n", name); printf("OPTIONS:\n"); printf("\t-d \t\tthe device index (default is 0)\n"); +#ifdef DEBUG + printf("\t-D \t\t\tdump the last frame to a file (only active in DEBUG mode)\n"); +#endif printf("\t-f \tthe input device format\n"); printf("\t-i \t\tthe input path\n"); printf("\t-o \t\ta comma separated list of input format options\n"); @@ -640,8 +652,9 @@ int main(int argc, char *argv[]) int format = AM7XXX_IMAGE_FORMAT_JPEG; am7xxx_context *ctx; am7xxx_device *dev; + int dump_frame = 0; - while ((opt = getopt(argc, argv, "d:f:i:o:s:uF:q:l:p:z:h")) != -1) { + while ((opt = getopt(argc, argv, "d:Df:i:o:s:uF:q:l:p:z:h")) != -1) { switch (opt) { case 'd': device_index = atoi(optarg); @@ -651,6 +664,12 @@ int main(int argc, char *argv[]) goto out; } break; + case 'D': + dump_frame = 1; +#ifndef DEBUG + fprintf(stderr, "Warning: the -D option is only active in DEBUG mode.\n"); +#endif + break; case 'f': input_format_string = strdup(optarg); break; @@ -849,7 +868,8 @@ int main(int argc, char *argv[]) upscale, quality, format, - dev); + dev, + dump_frame); if (ret < 0) { fprintf(stderr, "am7xxx_play failed\n"); goto cleanup; diff --git a/examples/picoproj.c b/examples/picoproj.c index d335ed1..2069799 100644 --- a/examples/picoproj.c +++ b/examples/picoproj.c @@ -4,7 +4,7 @@ * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 2 of the License, or + * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, diff --git a/src/am7xxx.c b/src/am7xxx.c index ebc403e..76df87d 100644 --- a/src/am7xxx.c +++ b/src/am7xxx.c @@ -34,7 +34,7 @@ * taken from: http://unixwiz.net/techtips/gnu-c-attributes.html) */ #ifndef __GNUC__ -# define __attribute__(x) /*NOTHING*/ +# define __attribute__(x) /* NOTHING */ #endif /* Control shared library symbols visibility */ @@ -53,7 +53,7 @@ static void log_message(am7xxx_context *ctx, int level, - const char *function, + const char *function_name, int line, const char *fmt, ...) __attribute__ ((format (printf, 5, 6))); @@ -341,7 +341,7 @@ static inline unsigned int in_80chars(unsigned int i) { /* The 3 below is the length of "xx " where xx is the hex string * representation of a byte */ - return ((i+1) % (80/3)); + return ((i + 1) % (80 / 3)); } static void trace_dump_buffer(am7xxx_context *ctx, const char *message, @@ -381,12 +381,13 @@ static void trace_dump_buffer(am7xxx_context *ctx, const char *message, static int read_data(am7xxx_device *dev, uint8_t *buffer, unsigned int len) { int ret; - int transferred = 0; + int transferred; + transferred = 0; ret = libusb_bulk_transfer(dev->usb_device, 0x81, buffer, len, &transferred, 0); if (ret != 0 || (unsigned int)transferred != len) { - error(dev->ctx, "ret: %d\ttransferred: %d (expected %u)\n", - ret, transferred, len); + error(dev->ctx, "%s. Transferred: %d (expected %u)\n", + libusb_error_name(ret), transferred, len); return ret; } @@ -398,14 +399,15 @@ static int read_data(am7xxx_device *dev, uint8_t *buffer, unsigned int len) static int send_data(am7xxx_device *dev, uint8_t *buffer, unsigned int len) { int ret; - int transferred = 0; + int transferred; trace_dump_buffer(dev->ctx, "sending -->", buffer, len); + transferred = 0; ret = libusb_bulk_transfer(dev->usb_device, 0x1, buffer, len, &transferred, 0); if (ret != 0 || (unsigned int)transferred != len) { - error(dev->ctx, "ret: %d\ttransferred: %d (expected %u)\n", - ret, transferred, len); + error(dev->ctx, "%s. Transferred: %d (expected %u)\n", + libusb_error_name(ret), transferred, len); return ret; } @@ -489,8 +491,8 @@ static int send_data_async(am7xxx_device *dev, uint8_t *buffer, unsigned int len /* Make a copy of the buffer so the caller can safely reuse it just * after libusb_submit_transfer() has returned. This technique - * requires more allocations than a proper double-buffering approach - * but it takes a lot less code. */ + * requires more dynamic allocations compared to a proper + * double-buffering approach but it takes a lot less code. */ transfer_buffer = malloc(len); if (transfer_buffer == NULL) { error(dev->ctx, "cannot allocate transfer buffer (%s)\n", @@ -626,7 +628,7 @@ static int send_command(am7xxx_device *dev, am7xxx_packet_type type) * set up */ static void log_message(am7xxx_context *ctx, int level, - const char *function, + const char *function_name, int line, const char *fmt, ...) @@ -634,8 +636,8 @@ static void log_message(am7xxx_context *ctx, va_list ap; if (level == AM7XXX_LOG_FATAL || (ctx && level <= ctx->log_level)) { - if (function) { - fprintf(stderr, "%s", function); + if (function_name) { + fprintf(stderr, "%s", function_name); if (line) fprintf(stderr, "[%d]", line); fprintf(stderr, ": "); @@ -662,7 +664,7 @@ static am7xxx_device *add_new_device(am7xxx_context *ctx, new_device = malloc(sizeof(*new_device)); if (new_device == NULL) { - fatal("cannot allocate a new device (%s)\n", strerror(errno)); + debug(ctx, "cannot allocate a new device (%s)\n", strerror(errno)); return NULL; } memset(new_device, 0, sizeof(*new_device)); @@ -702,6 +704,119 @@ static am7xxx_device *find_device(am7xxx_context *ctx, return current; } +static int open_device(am7xxx_context *ctx, + unsigned int device_index, + libusb_device *usb_dev, + am7xxx_device **dev) +{ + int ret; + int current_configuration; + + *dev = find_device(ctx, device_index); + if (*dev == NULL) { + ret = -ENODEV; + goto out; + } + + /* the usb device has already been opened */ + if ((*dev)->usb_device) { + ret = 1; + goto out; + } + + ret = libusb_open(usb_dev, &((*dev)->usb_device)); + if (ret < 0) { + debug(ctx, "libusb_open failed: %s\n", libusb_error_name(ret)); + goto out; + } + + /* XXX, the device is now open, if any of the calls below fail we need + * to close it again before bailing out. + */ + + current_configuration = -1; + ret = libusb_get_configuration((*dev)->usb_device, + ¤t_configuration); + if (ret < 0) { + debug(ctx, "libusb_get_configuration failed: %s\n", + libusb_error_name(ret)); + goto out_libusb_close; + } + + if (current_configuration != (*dev)->desc->configuration) { + /* + * In principle, before setting a new configuration, kernel + * drivers should be detached from _all_ interfaces; for + * example calling something like the following "invented" + * function _before_ setting the new configuration: + * + * libusb_detach_all_kernel_drivers((*dev)->usb_device); + * + * However, in practice, this is not necessary for most + * devices as they have only one configuration. + * + * When a device only has one configuration: + * + * - if there was a kernel driver bound to the device, it + * had already set the configuration and the call below + * will be skipped; + * + * - if no kernel driver was bound to the device, the call + * below will suceed. + */ + ret = libusb_set_configuration((*dev)->usb_device, + (*dev)->desc->configuration); + if (ret < 0) { + debug(ctx, "libusb_set_configuration failed: %s\n", + libusb_error_name(ret)); + debug(ctx, "Cannot set configuration %hhu\n", + (*dev)->desc->configuration); + goto out_libusb_close; + } + } + + libusb_set_auto_detach_kernel_driver((*dev)->usb_device, 1); + + ret = libusb_claim_interface((*dev)->usb_device, + (*dev)->desc->interface_number); + if (ret < 0) { + debug(ctx, "libusb_claim_interface failed: %s\n", + libusb_error_name(ret)); + debug(ctx, "Cannot claim interface %hhu\n", + (*dev)->desc->interface_number); + goto out_libusb_close; + } + + /* Checking that the configuration has not changed, as suggested in + * http://libusb.sourceforge.net/api-1.0/caveats.html + */ + current_configuration = -1; + ret = libusb_get_configuration((*dev)->usb_device, + ¤t_configuration); + if (ret < 0) { + debug(ctx, "libusb_get_configuration after claim failed: %s\n", + libusb_error_name(ret)); + goto out_libusb_release_interface; + } + + if (current_configuration != (*dev)->desc->configuration) { + debug(ctx, "libusb configuration changed (expected: %hhu, current: %d\n", + (*dev)->desc->configuration, current_configuration); + ret = -EINVAL; + goto out_libusb_release_interface; + } +out: + return ret; + +out_libusb_release_interface: + libusb_release_interface((*dev)->usb_device, + (*dev)->desc->interface_number); +out_libusb_close: + libusb_close((*dev)->usb_device); + (*dev)->usb_device = NULL; + return ret; +} + typedef enum { SCAN_OP_BUILD_DEVLIST, SCAN_OP_OPEN_DEVICE, @@ -711,13 +826,14 @@ typedef enum { * This is where the central logic of multi-device support is. * * When 'op' == SCAN_OP_BUILD_DEVLIST the parameters 'open_device_index' and - * 'dev' are ignored; the function returns 0 on success and a negative value + * 'dev' are ignored; the function returns 0 on success or a negative value * on error. * * When 'op' == SCAN_OP_OPEN_DEVICE the function opens the supported USB * device with index 'open_device_index' and returns the correspondent - * am7xxx_device in the 'dev' parameter; the function returns 0 on success, - * 1 if the device was already open and a negative value on error. + * am7xxx_device in the 'dev' parameter; the function returns the value from + * open_device(), which is 0 on success, 1 if the device was already open or + * a negative value on error. * * NOTES: * if scan_devices() fails when called with 'op' == SCAN_OP_BUILD_DEVLIST, @@ -728,7 +844,7 @@ static int scan_devices(am7xxx_context *ctx, scan_op op, unsigned int open_device_index, am7xxx_device **dev) { ssize_t num_devices; - libusb_device** list; + libusb_device **list; unsigned int current_index; int i; int ret; @@ -780,51 +896,16 @@ static int scan_devices(am7xxx_context *ctx, scan_op op, } else if (op == SCAN_OP_OPEN_DEVICE && current_index == open_device_index) { - *dev = find_device(ctx, open_device_index); - if (*dev == NULL) { - ret = -ENODEV; - goto out; - } - - /* the usb device has already been opened */ - if ((*dev)->usb_device) { - debug(ctx, "(*dev)->usb_device already set\n"); - ret = 1; - goto out; - } - - ret = libusb_open(list[i], &((*dev)->usb_device)); - if (ret < 0) { - debug(ctx, "libusb_open failed\n"); - goto out; - } - - /* XXX, the device is now open, if any - * of the calls below fail we need to - * close it again before bailing out. - */ - - ret = libusb_set_configuration((*dev)->usb_device, - (*dev)->desc->configuration); - if (ret < 0) { - debug(ctx, "libusb_set_configuration failed\n"); - debug(ctx, "Cannot set configuration %hhu\n", - (*dev)->desc->configuration); - goto out_libusb_close; - } - - ret = libusb_claim_interface((*dev)->usb_device, - (*dev)->desc->interface_number); - if (ret < 0) { - debug(ctx, "libusb_claim_interface failed\n"); - debug(ctx, "Cannot claim interface %hhu\n", - (*dev)->desc->interface_number); -out_libusb_close: - libusb_close((*dev)->usb_device); - (*dev)->usb_device = NULL; - goto out; - } + ret = open_device(ctx, + open_device_index, + list[i], + dev); + if (ret < 0) + debug(ctx, "open_device failed\n"); + /* exit the loop unconditionally after + * attempting to open the device + * requested by the user */ goto out; } current_index++; @@ -832,7 +913,8 @@ out_libusb_close: } } - /* if we made it up to here we didn't find any device to open */ + /* if we made it up to here when op == SCAN_OP_OPEN_DEVICE, + * no devices to open had been found. */ if (op == SCAN_OP_OPEN_DEVICE) { error(ctx, "Cannot find any device to open\n"); ret = -ENODEV; @@ -1020,8 +1102,10 @@ AM7XXX_PUBLIC int am7xxx_init(am7xxx_context **ctx) (*ctx)->log_level = AM7XXX_LOG_TRACE; ret = libusb_init(&((*ctx)->usb_context)); - if (ret < 0) + if (ret < 0) { + error(*ctx, "libusb_init failed: %s\n", libusb_error_name(ret)); goto out_free_context; + } libusb_set_debug((*ctx)->usb_context, LIBUSB_LOG_LEVEL_INFO); diff --git a/src/am7xxx.h b/src/am7xxx.h index 4a97f69..d103c22 100644 --- a/src/am7xxx.h +++ b/src/am7xxx.h @@ -252,7 +252,7 @@ int am7xxx_send_image(am7xxx_device *dev, * This is the function that actually makes the device display something. * Static pictures can be sent just once and the device will keep showing them * until another image get sent or some command resets or turns off the display. - * + * * @note This _async() variant makes a copy of the image buffer, so the caller * is free to reuse the buffer just after the function returns. * diff --git a/src/portable_endian.h b/src/portable_endian.h index 1741f18..6bc9a73 100644 --- a/src/portable_endian.h +++ b/src/portable_endian.h @@ -1,4 +1,4 @@ -/* +/* * Public domain, stripped down version of: * https://gist.github.com/panzi/6856583 */