From 53ec7b26224b9955fee6f01a44350da29488fb87 Mon Sep 17 00:00:00 2001 From: Antonio Ospite Date: Mon, 19 Mar 2012 22:13:04 +0100 Subject: [PATCH 01/16] examples: add a -l option to am7xxx-play Allow setting the verbosity level of log messages. --- examples/am7xxx-play.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/examples/am7xxx-play.c b/examples/am7xxx-play.c index f7e069a..a661758 100644 --- a/examples/am7xxx-play.c +++ b/examples/am7xxx-play.c @@ -564,6 +564,7 @@ static void usage(char *name) printf("\t\t\t\t\t1 - JPEG\n"); printf("\t\t\t\t\t2 - NV12\n"); printf("\t-q \t\t\tquality of jpeg sent to the device, between 1 and 100\n"); + printf("\t-l \t\tthe verbosity level of libam7xxx output (0-5)\n"); printf("\t-h \t\t\tthis help message\n"); printf("\n\nEXAMPLES OF USE:\n"); printf("\t%s -f x11grab -i :0.0 -o video_size=800x480\n", name); @@ -585,11 +586,12 @@ int main(int argc, char *argv[]) unsigned int rescale_method = SWS_BICUBIC; unsigned int upscale = 0; unsigned int quality = 95; + int log_level = AM7XXX_LOG_INFO; int format = AM7XXX_IMAGE_FORMAT_JPEG; am7xxx_context *ctx; am7xxx_device *dev; - while ((opt = getopt(argc, argv, "f:i:o:s:uF:q:h")) != -1) { + while ((opt = getopt(argc, argv, "f:i:o:s:uF:q:l:h")) != -1) { switch (opt) { case 'f': input_format_string = strdup(optarg); @@ -662,6 +664,13 @@ int main(int argc, char *argv[]) goto out;; } break; + case 'l': + log_level = atoi(optarg); + if (log_level < AM7XXX_LOG_FATAL || log_level > AM7XXX_LOG_TRACE) { + fprintf(stderr, "Unsupported log level, falling back to AM7XXX_LOG_ERROR\n"); + log_level = AM7XXX_LOG_ERROR; + } + break; case 'h': usage(argv[0]); ret = 0; @@ -713,6 +722,8 @@ int main(int argc, char *argv[]) goto out; } + am7xxx_set_log_level(ctx, log_level); + ret = am7xxx_open_device(ctx, &dev, 0); if (ret < 0) { perror("am7xxx_open_device"); -- 2.1.4 From b19775ece86f40df15ffadcb358c8896bc847482 Mon Sep 17 00:00:00 2001 From: Antonio Ospite Date: Tue, 20 Mar 2012 22:59:03 +0100 Subject: [PATCH 02/16] examples: set proper return codes in am7xxx-play Set the return codes explicitly on the error path of functions not returning an int error value. --- examples/am7xxx-play.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/examples/am7xxx-play.c b/examples/am7xxx-play.c index a661758..56fd8b2 100644 --- a/examples/am7xxx-play.c +++ b/examples/am7xxx-play.c @@ -291,6 +291,7 @@ static int am7xxx_play(const char *input_format_string, picture_raw = avcodec_alloc_frame(); if (picture_raw == NULL) { fprintf(stderr, "cannot allocate the raw picture frame!"); + ret = -ENOMEM; goto cleanup_output; } @@ -298,6 +299,7 @@ static int am7xxx_play(const char *input_format_string, picture_scaled = avcodec_alloc_frame(); if (picture_scaled == NULL) { fprintf(stderr, "cannot allocate the scaled picture!\n"); + ret = -ENOMEM; goto cleanup_picture_raw; } @@ -308,6 +310,7 @@ static int am7xxx_play(const char *input_format_string, out_buf = av_malloc(out_buf_size * sizeof(uint8_t)); if (out_buf == NULL) { fprintf(stderr, "cannot allocate output data buffer!\n"); + ret = -ENOMEM; goto cleanup_picture_scaled; } @@ -329,6 +332,7 @@ static int am7xxx_play(const char *input_format_string, NULL, NULL, NULL); if (sw_scale_ctx == NULL) { fprintf(stderr, "cannot set up the rescaling context!\n"); + ret = -EINVAL; goto cleanup_out_buf; } -- 2.1.4 From e4f378d2a205de26935e94d7248bfbc58738d422 Mon Sep 17 00:00:00 2001 From: Antonio Ospite Date: Wed, 21 Mar 2012 12:06:16 +0100 Subject: [PATCH 03/16] cmake: make stricter compilation checks conditional On some systems building with options like -Werror is just impractical. --- CMakeLists.txt | 20 ++++++++++++-------- HACKING.asciidoc | 2 +- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9950111..41cb527 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -16,6 +16,8 @@ set(PROJECT_APIVER set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake_modules/") +OPTION(STRICT_COMPILATION_CHECKS "Enable stricter compilation checks" OFF) + include (MaintenanceTools) set(EXECUTABLE_OUTPUT_PATH ${CMAKE_BINARY_DIR}/bin) @@ -37,13 +39,6 @@ if (CMAKE_COMPILER_IS_GNUCC) set(CMAKE_C_FLAGS "-std=c99 -pedantic -Wall -Wextra") endif() - # Don't make pedantic checks errors, - # as vanilla libusb-1.0.8 can't live with that - #add_flags(CMAKE_C_FLAGS -pedantic-errors) - - # GCC >= 4.6 - #add_flags(CMAKE_C_FLAGS -Wunused-but-set-variable) - add_flags(CMAKE_C_FLAGS -fno-common -Wall @@ -72,9 +67,18 @@ if (CMAKE_COMPILER_IS_GNUCC) -Wwrite-strings -fstack-protector --param=ssp-buffer-size=4) + + if (STRICT_COMPILATION_CHECKS) + add_flags(CMAKE_C_FLAGS + -Werror + # NOTE: Vanilla libusb-1.0.8 can't live with -pedantic-errors + -pedantic-errors + # NOTE: GCC >= 4.6 is needed for -Wunused-but-set-variable + -Wunused-but-set-variable) + endif() endif() -set(CMAKE_C_FLAGS_DEBUG "-O0 -ggdb -DDEBUG=1 -Werror") +set(CMAKE_C_FLAGS_DEBUG "-O0 -ggdb -DDEBUG=1") set(CMAKE_C_FLAGS_RELEASE "-O2") set(CMAKE_C_FLAGS_RELWITHDEBINFO "-O2 -g") diff --git a/HACKING.asciidoc b/HACKING.asciidoc index cd9486d..99dc15e 100644 --- a/HACKING.asciidoc +++ b/HACKING.asciidoc @@ -11,7 +11,7 @@ The suggested way to hack on the project is: $ mkdir build $ cd build - $ cmake ../ -DCMAKE_BUILD_TYPE=debug + $ cmake ../ -DCMAKE_BUILD_TYPE=debug -DSTRICT_COMPILATION_CHECKS=ON $ make If you want to check the code with the ''sparse'' static analysis tool you -- 2.1.4 From 7b5a3f952c23daed53a37422db0972950071fc55 Mon Sep 17 00:00:00 2001 From: Antonio Ospite Date: Wed, 21 Mar 2012 14:47:20 +0100 Subject: [PATCH 04/16] am7xxx: round scaled_height and scaled_width Round when converting from float to int, this is more like what the user expects about image dimensions. --- src/CMakeLists.txt | 6 ++++-- src/am7xxx.c | 5 +++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index bec1d5c..e09a282 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -22,8 +22,10 @@ endif() install(TARGETS am7xxx-static DESTINATION "${CMAKE_INSTALL_PREFIX}/lib") -target_link_libraries(am7xxx ${LIBUSB_1_LIBRARIES}) -target_link_libraries(am7xxx-static ${LIBUSB_1_LIBRARIES}) +find_library(MATH_LIB m) + +target_link_libraries(am7xxx ${MATH_LIB} ${LIBUSB_1_LIBRARIES}) +target_link_libraries(am7xxx-static ${MATH_LIB} ${LIBUSB_1_LIBRARIES}) # Install the header files install(FILES "am7xxx.h" diff --git a/src/am7xxx.c b/src/am7xxx.c index 6574100..1035e23 100644 --- a/src/am7xxx.c +++ b/src/am7xxx.c @@ -22,6 +22,7 @@ #include #include #include +#include #include "am7xxx.h" #include "serialize.h" @@ -734,14 +735,14 @@ int am7xxx_calc_scaled_image_dimensions(am7xxx_device *dev, */ debug(dev->ctx, "CASE 1, original image wider, adjust the scaled height\n"); *scaled_width = device_info.native_width; - *scaled_height = (unsigned int)(original_height / width_ratio); + *scaled_height = (unsigned int)lroundf(original_height / width_ratio); } else if (width_ratio < height_ratio) { /* * The input is proportionally "taller" than the device viewport * so its width needs to be adjusted */ debug(dev->ctx, "CASE 2 original image taller, adjust the scaled width\n"); - *scaled_width = (unsigned int)(original_width / height_ratio); + *scaled_width = (unsigned int)lroundf(original_width / height_ratio); *scaled_height = device_info.native_height; } else { debug(dev->ctx, "CASE 3, just rescale, same aspect ratio already\n"); -- 2.1.4 From 63e424dfcc3e03699b350e3cbd1ae3a7968b8cf6 Mon Sep 17 00:00:00 2001 From: Antonio Ospite Date: Fri, 23 Mar 2012 17:03:36 +0100 Subject: [PATCH 05/16] sm7xxx-play: add missing newline on some error messages --- examples/am7xxx-play.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/examples/am7xxx-play.c b/examples/am7xxx-play.c index 5aa53ae..b28ecec 100644 --- a/examples/am7xxx-play.c +++ b/examples/am7xxx-play.c @@ -84,7 +84,7 @@ static int video_input_init(struct video_input_ctx *input_ctx, /* get information on the input stream (e.g. format, bitrate, framerate) */ ret = avformat_find_stream_info(input_format_ctx, NULL); if (ret < 0) { - fprintf(stderr, "cannot get information on the stream"); + fprintf(stderr, "cannot get information on the stream\n"); goto cleanup; } @@ -115,7 +115,7 @@ static int video_input_init(struct video_input_ctx *input_ctx, /* find the decoder for the video stream */ input_codec = avcodec_find_decoder(input_codec_ctx->codec_id); if (input_codec == NULL) { - fprintf(stderr, "input_codec is NULL!"); + fprintf(stderr, "input_codec is NULL!\n"); ret = -ENOTSUP; goto cleanup; } @@ -163,7 +163,7 @@ static int video_output_init(struct video_output_ctx *output_ctx, int ret; if (input_ctx == NULL) { - fprintf(stderr, "input_ctx must not be NULL!"); + fprintf(stderr, "input_ctx must not be NULL!\n"); ret = -EINVAL; goto out; } @@ -171,7 +171,7 @@ static int video_output_init(struct video_output_ctx *output_ctx, /* create the encoder context */ output_codec_ctx = avcodec_alloc_context3(NULL); if (output_codec_ctx == NULL) { - fprintf(stderr, "cannot allocate output codec context!"); + fprintf(stderr, "cannot allocate output codec context!\n"); ret = -ENOMEM; goto out; } @@ -290,7 +290,7 @@ static int am7xxx_play(const char *input_format_string, /* allocate an input frame */ picture_raw = avcodec_alloc_frame(); if (picture_raw == NULL) { - fprintf(stderr, "cannot allocate the raw picture frame!"); + fprintf(stderr, "cannot allocate the raw picture frame!\n"); ret = -ENOMEM; goto cleanup_output; } -- 2.1.4 From b2281e337903266b7c276d5e1ccc0542c109fa70 Mon Sep 17 00:00:00 2001 From: Antonio Ospite Date: Fri, 23 Mar 2012 22:01:45 +0100 Subject: [PATCH 06/16] doc: add examples to the Doxygen documentation --- doc/Doxyfile.in | 7 ++++--- examples/am7xxx-play.c | 6 ++++++ examples/picoproj.c | 5 +++++ 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/doc/Doxyfile.in b/doc/Doxyfile.in index a1554c4..4e6a877 100644 --- a/doc/Doxyfile.in +++ b/doc/Doxyfile.in @@ -96,7 +96,8 @@ WARN_LOGFILE = # configuration options related to the input files #--------------------------------------------------------------------------- INPUT = @CMAKE_CURRENT_SOURCE_DIR@/ \ - @CMAKE_SOURCE_DIR@/src/ + @CMAKE_SOURCE_DIR@/src/ \ + @CMAKE_SOURCE_DIR@/examples/ INPUT_ENCODING = UTF-8 FILE_PATTERNS = *.dox \ *.h \ @@ -106,8 +107,8 @@ EXCLUDE = EXCLUDE_SYMLINKS = NO EXCLUDE_PATTERNS = EXCLUDE_SYMBOLS = -EXAMPLE_PATH = -EXAMPLE_PATTERNS = +EXAMPLE_PATH = @CMAKE_SOURCE_DIR@/examples/ +EXAMPLE_PATTERNS = *.c EXAMPLE_RECURSIVE = NO IMAGE_PATH = INPUT_FILTER = diff --git a/examples/am7xxx-play.c b/examples/am7xxx-play.c index b28ecec..54f92e9 100644 --- a/examples/am7xxx-play.c +++ b/examples/am7xxx-play.c @@ -17,6 +17,12 @@ * along with this program. If not, see . */ +/** + * @example examples/am7xxx-play.c + * am7xxx-play uses libavdevice, libavformat, libavcodec and libswscale to + * decode the input, encode it to jpeg and display it with libam7xxx. + */ + #include #include #include diff --git a/examples/picoproj.c b/examples/picoproj.c index c3b199c..2970585 100644 --- a/examples/picoproj.c +++ b/examples/picoproj.c @@ -16,6 +16,11 @@ * along with this program. If not, see . */ +/** + * @example examples/picoproj.c + * A minimal example to show how to use libam7xxx to show a static image. + */ + #include #include #include -- 2.1.4 From 500e15607006dbf85cb9f725cfaf650999b9a187 Mon Sep 17 00:00:00 2001 From: Antonio Ospite Date: Fri, 23 Mar 2012 23:32:59 +0100 Subject: [PATCH 07/16] examples: make picoproj usage look more like am7xxx-play one --- examples/picoproj.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/examples/picoproj.c b/examples/picoproj.c index 2970585..8af2fbc 100644 --- a/examples/picoproj.c +++ b/examples/picoproj.c @@ -37,14 +37,16 @@ static void usage(char *name) printf("usage: %s [OPTIONS]\n\n", name); printf("OPTIONS:\n"); printf("\t-f \t\tthe image file to upload\n"); - printf("\t-F \t\tthe image format to use (default is JPEG).\n"); + printf("\t-F \t\tthe image format to use (default is JPEG)\n"); printf("\t\t\t\tSUPPORTED FORMATS:\n"); printf("\t\t\t\t\t1 - JPEG\n"); - printf("\t\t\t\t\t2 - YUV - NV12\n"); + printf("\t\t\t\t\t2 - NV12\n"); printf("\t-l \t\tthe verbosity level of libam7xxx output (0-5)\n"); printf("\t-W \tthe width of the image to upload\n"); printf("\t-H \tthe height of the image to upload\n"); printf("\t-h \t\t\tthis help message\n"); + printf("\n\nEXAMPLE OF USE:\n"); + printf("\t%s -f file.jpg -F 1 -l 5 -W 800 -H 480\n", name); } int main(int argc, char *argv[]) -- 2.1.4 From 32e0039fd876db8fca014a1b89310427045bd5b3 Mon Sep 17 00:00:00 2001 From: Antonio Ospite Date: Sat, 24 Mar 2012 00:26:59 +0100 Subject: [PATCH 08/16] examples: rephrase picoproj example description This is to avoid repeating 'show' two times in the same sentence. --- examples/picoproj.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/picoproj.c b/examples/picoproj.c index 8af2fbc..7ae1296 100644 --- a/examples/picoproj.c +++ b/examples/picoproj.c @@ -18,7 +18,7 @@ /** * @example examples/picoproj.c - * A minimal example to show how to use libam7xxx to show a static image. + * A minimal example to show how to use libam7xxx to display a static image. */ #include -- 2.1.4 From 11e6f8b120d9b38c5f788cb9a04aed24d2e11ce4 Mon Sep 17 00:00:00 2001 From: Antonio Ospite Date: Sat, 24 Mar 2012 00:01:25 +0100 Subject: [PATCH 09/16] doc: add a link to the public API on the main page --- doc/DoxygenMainpage.dox | 2 ++ 1 file changed, 2 insertions(+) diff --git a/doc/DoxygenMainpage.dox b/doc/DoxygenMainpage.dox index 0d0cd62..2453dc2 100644 --- a/doc/DoxygenMainpage.dox +++ b/doc/DoxygenMainpage.dox @@ -16,6 +16,8 @@ non-Windows Operating Systems like GNU/Linux or Android/Linux just to name a few, and on non-PC platforms like for instance mobile phones, tablets or game consoles. +Check @link am7xxx.h @endlink for the public API documentation. + @section libam7xxxSupportedDevices Supported Devices - Acer C110 -- 2.1.4 From 7125b5256322f0055f19d2a478236cd69fcf64b3 Mon Sep 17 00:00:00 2001 From: Antonio Ospite Date: Sat, 24 Mar 2012 00:25:57 +0100 Subject: [PATCH 10/16] doc: add generation of man pages from asciidoc sources --- cmake_modules/FindAsciidoc.cmake | 27 +++++++++++ doc/CMakeLists.txt | 2 + doc/man/CMakeLists.txt | 16 +++++++ doc/man/am7xxx-play.1.txt | 100 +++++++++++++++++++++++++++++++++++++++ doc/man/picoproj.1.txt | 80 +++++++++++++++++++++++++++++++ 5 files changed, 225 insertions(+) create mode 100644 cmake_modules/FindAsciidoc.cmake create mode 100644 doc/man/CMakeLists.txt create mode 100644 doc/man/am7xxx-play.1.txt create mode 100644 doc/man/picoproj.1.txt diff --git a/cmake_modules/FindAsciidoc.cmake b/cmake_modules/FindAsciidoc.cmake new file mode 100644 index 0000000..9b3e414 --- /dev/null +++ b/cmake_modules/FindAsciidoc.cmake @@ -0,0 +1,27 @@ +# - Find Asciidoc +# this module looks for asciidoc +# +# ASCIIDOC_EXECUTABLE - the full path to asciidoc +# ASCIIDOC_A2X_EXECUTABLE - the full path to asciidoc's a2x +# ASCIIDOC_FOUND - If false, don't attempt to use asciidoc. +# +# Taken from: +# http://lissyx.dyndns.org/redmine/projects/qpdfpresenterconsole/repository/revisions/master/raw/cmake/FindAsciidoc.cmake + +FIND_PROGRAM(ASCIIDOC_EXECUTABLE asciidoc) +FIND_PROGRAM(ASCIIDOC_A2X_EXECUTABLE a2x) + +MARK_AS_ADVANCED( +ASCIIDOC_EXECUTABLE +ASCIIDOC_A2X_EXECUTABLE +) + +IF ((NOT ASCIIDOC_EXECUTABLE) OR (NOT ASCIIDOC_A2X_EXECUTABLE)) +SET(ASCIIDOC_FOUND "NO") +ELSE ((NOT ASCIIDOC_EXECUTABLE) OR (NOT ASCIIDOC_A2X_EXECUTABLE)) +SET(ASCIIDOC_FOUND "YES") +ENDIF ((NOT ASCIIDOC_EXECUTABLE) OR (NOT ASCIIDOC_A2X_EXECUTABLE)) + +IF (NOT ASCIIDOC_FOUND AND Asciidoc_FIND_REQUIRED) +MESSAGE(FATAL_ERROR "Could not find asciidoc") +ENDIF (NOT ASCIIDOC_FOUND AND Asciidoc_FIND_REQUIRED) diff --git a/doc/CMakeLists.txt b/doc/CMakeLists.txt index ce111b2..0569f9d 100644 --- a/doc/CMakeLists.txt +++ b/doc/CMakeLists.txt @@ -13,3 +13,5 @@ if(DOXYGEN_FOUND) DESTINATION "${CMAKE_INSTALL_PREFIX}/share/doc/${CMAKE_PROJECT_NAME}") endif(DOXYGEN_FOUND) + +add_subdirectory(man) diff --git a/doc/man/CMakeLists.txt b/doc/man/CMakeLists.txt new file mode 100644 index 0000000..8029513 --- /dev/null +++ b/doc/man/CMakeLists.txt @@ -0,0 +1,16 @@ +# add a target to generate man pages with asciidoc +find_package(Asciidoc) +if(ASCIIDOC_FOUND) + add_custom_target(manpages + ${ASCIIDOC_A2X_EXECUTABLE} -f manpage ${CMAKE_CURRENT_SOURCE_DIR}/am7xxx-play.1.txt -D ${CMAKE_CURRENT_BINARY_DIR} + COMMAND ${ASCIIDOC_A2X_EXECUTABLE} -f manpage ${CMAKE_CURRENT_SOURCE_DIR}/picoproj.1.txt -D ${CMAKE_CURRENT_BINARY_DIR} + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} + COMMENT "Generating man pages with Asciidoc" VERBATIM + ) + +install(FILES + ${DOC_OUTPUT_PATH}/man/am7xxx-play.1 + ${DOC_OUTPUT_PATH}/man/picoproj.1 + DESTINATION "${CMAKE_INSTALL_PREFIX}/share/man/man1/") + +endif(ASCIIDOC_FOUND) diff --git a/doc/man/am7xxx-play.1.txt b/doc/man/am7xxx-play.1.txt new file mode 100644 index 0000000..5054da4 --- /dev/null +++ b/doc/man/am7xxx-play.1.txt @@ -0,0 +1,100 @@ +AM7XXX-PLAY(1) +============== +:doctype: manpage + + +NAME +---- +am7xxx-play - play stuff on an am7xxx device (e.g. Acer C110, PicoPix 1020) + + +SYNOPSIS +-------- +*am7xxx-play* ['OPTIONS'] + + +DESCRIPTION +----------- +am7xxx-play(1) uses libavdevice, libavformat, libavcodec and libswscale to +decode the input, encode it to jpeg and display it with libam7xxx. + + +OPTIONS +------- +*-f* '':: + the input device format + +*-i* '':: + the input path + +*-o* '':: + a comma separated list of input format options ++ +EXAMPLE: ++ + -o draw_mouse=1,framerate=100,video_size=800x480 + +*-s* '':: + the rescaling method (see swscale.h) + +*-u*:: + upscale the image if smaller than the display dimensions + +*-F* '':: + the image format to use (default is JPEG) ++ +.SUPPORTED FORMATS: +* 1 - JPEG +* 2 - NV12 + +*-q* '':: + quality of jpeg sent to the device, between 1 and 100 + +*-l* '':: + the verbosity level of libam7xxx output (0-5) + +*-p* '':: + power level of device, between 0 (off) and 4 (maximum) + + WARNING: Level 2 and greater require the master AND + the slave connector to be plugged in. + +*-h*:: + this help message + + +EXAMPLES OF USE +--------------- + + am7xxx-play -f x11grab -i :0.0 -o video_size=800x480 + am7xxx-play -f fbdev -i /dev/fb0 + am7xxx-play -f video4linux2 -i /dev/video0 -o video_size=320x240,frame_rate=100 -u -q 90 + am7xxx-play -i http://download.blender.org/peach/bigbuckbunny_movies/BigBuckBunny_640x360.m4v + + +EXIT STATUS +----------- +*0*:: + Success + +*!0*:: + Failure (libam7xxx error; libav error) + + +AUTHORS +------- +Antonio Ospite and Reto Schneider + + +RESOURCES +--------- +Main web site: + + +COPYING +------- +Copyright \(C) 2012 Antonio Ospite + +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 3 of the License, or +(at your option) any later version. diff --git a/doc/man/picoproj.1.txt b/doc/man/picoproj.1.txt new file mode 100644 index 0000000..e26df26 --- /dev/null +++ b/doc/man/picoproj.1.txt @@ -0,0 +1,80 @@ +PICOPROJ(1) +=========== +:doctype: manpage + + +NAME +---- +picoproj - test program for libam7xxx + + +SYNOPSIS +-------- +*picoproj* ['OPTIONS'] + + +DESCRIPTION +----------- +picoproj(1) is a minimal example to show how to use libam7xxx to display a static image. + + +OPTIONS +------- + +*-f* '':: + the image file to upload + + +*-F* '':: + the image format to use (default is JPEG) ++ +.SUPPORTED FORMATS: +* 1 - JPEG +* 2 - NV12 + +*-l* '':: + the verbosity level of libam7xxx output (0-5) + +*-W* '':: + the width of the image to upload + +*-H* '':: + the height of the image to upload + +*-h*:: + this help message + + +EXAMPLE OF USE +-------------- + +picoproj -f file.jpg -F 1 -l 5 -W 800 -H 480 + + +EXIT STATUS +----------- +*0*:: + Success + +*!0*:: + Failure (libam7xxx error) + + +AUTHORS +------- +Antonio Ospite and Reto Schneider + + +RESOURCES +--------- +Main web site: + + +COPYING +------- +Copyright \(C) 2012 Antonio Ospite + +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 3 of the License, or +(at your option) any later version. -- 2.1.4 From 1886c8dcf5a9dd64cb5b8c25bed12a6f655b6613 Mon Sep 17 00:00:00 2001 From: Antonio Ospite Date: Mon, 26 Mar 2012 13:27:43 +0200 Subject: [PATCH 11/16] TODO: remove the entry about documenting the API with Doxygen --- TODO | 1 - 1 file changed, 1 deletion(-) diff --git a/TODO b/TODO index 137064e..ebd4ab4 100644 --- a/TODO +++ b/TODO @@ -1,3 +1,2 @@ -- Document the API with Doxygen. - Generate language bindings in order to use libam7xxx from other languages. - Handle signals in picoproj and do the proper cleanup -- 2.1.4 From a35c8213c4b5e05e6279b1abee16ff3d151c7b77 Mon Sep 17 00:00:00 2001 From: Antonio Ospite Date: Mon, 26 Mar 2012 13:50:05 +0200 Subject: [PATCH 12/16] Increase project number to 0.1.0 Version 0.1.0 is going to be the first libam7xxx stable release. --- CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 41cb527..75b7b7c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,8 +5,8 @@ set(PROJECT_DESCRIPTION "Communication library for Actions Micro AM7XXX based USB projectors and DPFs") set(PROJECT_VER_MAJOR 0) -set(PROJECT_VER_MINOR 0) -set(PROJECT_VER_PATCH 1) +set(PROJECT_VER_MINOR 1) +set(PROJECT_VER_PATCH 0) set(PROJECT_VER_EXTRA "") set(PROJECT_VER "${PROJECT_VER_MAJOR}.${PROJECT_VER_MINOR}.${PROJECT_VER_PATCH}${PROJECT_VER_EXTRA}") -- 2.1.4 From c4734c5b21355542c5718478f73ddf60ecf559fb Mon Sep 17 00:00:00 2001 From: Antonio Ospite Date: Wed, 28 Mar 2012 09:11:51 +0200 Subject: [PATCH 13/16] doc: make sure docs have been generated when installing This is done in three steps: - first a "custom install target" is created for each custom target which builds documentation; - then dependencies between those custom install targets and the correspondent "build" targets are added; - finally some code is added to ensure those "custom install targets" are called when the builtin install target is executed. --- doc/CMakeLists.txt | 10 ++++++++-- doc/man/CMakeLists.txt | 17 +++++++++++++---- 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/doc/CMakeLists.txt b/doc/CMakeLists.txt index 0569f9d..c1995f7 100644 --- a/doc/CMakeLists.txt +++ b/doc/CMakeLists.txt @@ -9,8 +9,14 @@ if(DOXYGEN_FOUND) COMMENT "Generating API documentation with Doxygen" VERBATIM ) - install(DIRECTORY ${DOC_OUTPUT_PATH}/html - DESTINATION "${CMAKE_INSTALL_PREFIX}/share/doc/${CMAKE_PROJECT_NAME}") + add_custom_target(install-doc + ${CMAKE_COMMAND} -E copy_directory + ${DOC_OUTPUT_PATH}/html + "${CMAKE_INSTALL_PREFIX}/share/doc/${CMAKE_PROJECT_NAME}/html" + ) + add_dependencies(install-doc doc) + + install(CODE "execute_process(COMMAND ${CMAKE_BUILD_TOOL} install-doc)") endif(DOXYGEN_FOUND) diff --git a/doc/man/CMakeLists.txt b/doc/man/CMakeLists.txt index 8029513..0083f4a 100644 --- a/doc/man/CMakeLists.txt +++ b/doc/man/CMakeLists.txt @@ -8,9 +8,18 @@ if(ASCIIDOC_FOUND) COMMENT "Generating man pages with Asciidoc" VERBATIM ) -install(FILES - ${DOC_OUTPUT_PATH}/man/am7xxx-play.1 - ${DOC_OUTPUT_PATH}/man/picoproj.1 - DESTINATION "${CMAKE_INSTALL_PREFIX}/share/man/man1/") + add_custom_target(install-manpages + ${CMAKE_COMMAND} -E make_directory + "${CMAKE_INSTALL_PREFIX}/share/man/man1/" + COMMAND ${CMAKE_COMMAND} -E copy + ${DOC_OUTPUT_PATH}/man/am7xxx-play.1 + "${CMAKE_INSTALL_PREFIX}/share/man/man1/" + COMMAND ${CMAKE_COMMAND} -E copy + ${DOC_OUTPUT_PATH}/man/picoproj.1 + "${CMAKE_INSTALL_PREFIX}/share/man/man1/" + ) + add_dependencies(install-manpages manpages) + + install(CODE "execute_process(COMMAND ${CMAKE_BUILD_TOOL} install-manpages)") endif(ASCIIDOC_FOUND) -- 2.1.4 From fd3677b9606851f5f29bcd663fd37137eb84abd3 Mon Sep 17 00:00:00 2001 From: Antonio Ospite Date: Wed, 28 Mar 2012 10:02:03 +0200 Subject: [PATCH 14/16] am7xxx: control shared library symbols visibility Export as public symbols only those really needed, without this change some symbols from serialize.c (get_8, get_le32, put_8, put_le32) were public too. Use -fvisibility=hidden so we don't need to explicitly mark symbols as local. --- CMakeLists.txt | 1 + src/am7xxx.c | 34 +++++++++++++++++++++++++--------- 2 files changed, 26 insertions(+), 9 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 75b7b7c..fa3f876 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -40,6 +40,7 @@ if (CMAKE_COMPILER_IS_GNUCC) endif() add_flags(CMAKE_C_FLAGS + -fvisibility=hidden -fno-common -Wall -Wextra diff --git a/src/am7xxx.c b/src/am7xxx.c index 1035e23..8087f89 100644 --- a/src/am7xxx.c +++ b/src/am7xxx.c @@ -36,6 +36,20 @@ # define __attribute__(x) /*NOTHING*/ #endif +/* Control shared library symbols visibility */ +#if defined _WIN32 || defined __CYGWIN__ + #define AM7XXX_PUBLIC __declspec(dllexport) + #define AM7XXX_LOCAL +#else + #if __GNUC__ >= 4 + #define AM7XXX_PUBLIC __attribute__ ((visibility ("default"))) + #define AM7XXX_LOCAL __attribute__ ((visibility ("hidden"))) + #else + #define AM7XXX_PUBLIC + #define AM7XXX_LOCAL + #endif +#endif + static void log_message(am7xxx_context *ctx, int level, const char *function, @@ -551,7 +565,9 @@ out: return ret; } -int am7xxx_init(am7xxx_context **ctx) +/* Public API */ + +AM7XXX_PUBLIC int am7xxx_init(am7xxx_context **ctx) { int ret = 0; @@ -590,7 +606,7 @@ out: return ret; } -void am7xxx_shutdown(am7xxx_context *ctx) +AM7XXX_PUBLIC void am7xxx_shutdown(am7xxx_context *ctx) { am7xxx_device *current; @@ -612,12 +628,12 @@ void am7xxx_shutdown(am7xxx_context *ctx) ctx = NULL; } -void am7xxx_set_log_level(am7xxx_context *ctx, am7xxx_log_level log_level) +AM7XXX_PUBLIC void am7xxx_set_log_level(am7xxx_context *ctx, am7xxx_log_level log_level) { ctx->log_level = log_level; } -int am7xxx_open_device(am7xxx_context *ctx, am7xxx_device **dev, +AM7XXX_PUBLIC int am7xxx_open_device(am7xxx_context *ctx, am7xxx_device **dev, unsigned int device_index) { int ret; @@ -639,7 +655,7 @@ int am7xxx_open_device(am7xxx_context *ctx, am7xxx_device **dev, return ret; } -int am7xxx_close_device(am7xxx_device *dev) +AM7XXX_PUBLIC int am7xxx_close_device(am7xxx_device *dev) { if (dev == NULL) { fatal("dev must not be NULL!\n"); @@ -653,7 +669,7 @@ int am7xxx_close_device(am7xxx_device *dev) return 0; } -int am7xxx_get_device_info(am7xxx_device *dev, +AM7XXX_PUBLIC int am7xxx_get_device_info(am7xxx_device *dev, am7xxx_device_info *device_info) { int ret; @@ -692,7 +708,7 @@ int am7xxx_get_device_info(am7xxx_device *dev, return 0; } -int am7xxx_calc_scaled_image_dimensions(am7xxx_device *dev, +AM7XXX_PUBLIC int am7xxx_calc_scaled_image_dimensions(am7xxx_device *dev, unsigned int upscale, unsigned int original_width, unsigned int original_height, @@ -754,7 +770,7 @@ int am7xxx_calc_scaled_image_dimensions(am7xxx_device *dev, return 0; } -int am7xxx_send_image(am7xxx_device *dev, +AM7XXX_PUBLIC int am7xxx_send_image(am7xxx_device *dev, am7xxx_image_format format, unsigned int width, unsigned int height, @@ -790,7 +806,7 @@ int am7xxx_send_image(am7xxx_device *dev, return send_data(dev, image, image_size); } -int am7xxx_set_power_mode(am7xxx_device *dev, am7xxx_power_mode mode) +AM7XXX_PUBLIC int am7xxx_set_power_mode(am7xxx_device *dev, am7xxx_power_mode mode) { int ret; struct am7xxx_header h = { -- 2.1.4 From 1caaf22426a7442b45872faf7f9f108d9c66baf0 Mon Sep 17 00:00:00 2001 From: Antonio Ospite Date: Wed, 28 Mar 2012 10:09:08 +0200 Subject: [PATCH 15/16] cosmetics: remove some trailing spaces --- CMakeLists.txt | 2 +- README.asciidoc | 2 +- cmake_modules/FindFFmpeg.cmake | 2 +- src/am7xxx.h | 6 +++--- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index fa3f876..a7dc551 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -13,7 +13,7 @@ set(PROJECT_VER set(PROJECT_APIVER "${PROJECT_VER_MAJOR}.${PROJECT_VER_MINOR}") -set(CMAKE_MODULE_PATH +set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake_modules/") OPTION(STRICT_COMPILATION_CHECKS "Enable stricter compilation checks" OFF) diff --git a/README.asciidoc b/README.asciidoc index 133c13b..7ccabf6 100644 --- a/README.asciidoc +++ b/README.asciidoc @@ -49,7 +49,7 @@ Examples of devices based on AM7XXX are: - Acer Series C pico projectors (C20, C110, C112): * http://www.acer.it/ac/it/IT/content/models/projector-c * http://support.acer.com/product/default.aspx?modelId=3888 - + - Philips/SagemCom PicoPix projectors (PPX 1020, PPX 1230, PPX 1430, PPX 1630): * http://www.philips.co.uk/c/pocket-projector/179840/cat/ diff --git a/cmake_modules/FindFFmpeg.cmake b/cmake_modules/FindFFmpeg.cmake index eabe5a0..1dc76d5 100644 --- a/cmake_modules/FindFFmpeg.cmake +++ b/cmake_modules/FindFFmpeg.cmake @@ -17,7 +17,7 @@ #and search the path which contain the libname/header.h (usefull for new version) #Then we need to include ${FFMPEG_libname_INCLUDE_DIRS} (in old version case, use by ffmpeg header and osg plugin code) -# (in new version case, use by ffmpeg header) +# (in new version case, use by ffmpeg header) #and ${FFMPEG_libname_INCLUDE_DIRS/libname} (in new version case, use by osg plugin code) diff --git a/src/am7xxx.h b/src/am7xxx.h index e67bcb6..51f9324 100644 --- a/src/am7xxx.h +++ b/src/am7xxx.h @@ -37,7 +37,7 @@ extern "C" { struct _am7xxx_context; typedef struct _am7xxx_context am7xxx_context; -/** +/** * @typedef am7xxx_device * * An opaque data type representing an am7xxx device. @@ -88,7 +88,7 @@ typedef enum { * An am7xxx device can operate in several power modes. A certain power mode * may have effect on the display brightness or on the device power * consumption. - * + * * @note Most am7xxx devices come with a Y-shaped USB cable with a Master and * a Slave connector, higher power modes may require that both connectors are * plugged in to the host system for the device to work properly. @@ -184,7 +184,7 @@ int am7xxx_get_device_info(am7xxx_device *dev, * Before sending images bigger than the device native dimensions the user * needs to rescale them, this utility function does the calculation in a way * that the original image aspect ratio is preserved. - * + * * @param[in] dev A pointer to the structure representing the device to get info of * @param[in] upscale Whether to calculate scaled dimensions for images smaller than the native dimensions * @param[in] original_width The width of the original image -- 2.1.4 From 4abcf9a0bc19a05995d14acc0a92cbf0ef61a91b Mon Sep 17 00:00:00 2001 From: Antonio Ospite Date: Wed, 28 Mar 2012 10:11:54 +0200 Subject: [PATCH 16/16] TODO: remove the entry about signals and picoproj picoproj is a minimal example and it is just meant to illustrate the API and run and exit quickly, it is not worth adding signal handling in it, that would just make the code more noisy. --- TODO | 1 - 1 file changed, 1 deletion(-) diff --git a/TODO b/TODO index ebd4ab4..63245b0 100644 --- a/TODO +++ b/TODO @@ -1,2 +1 @@ - Generate language bindings in order to use libam7xxx from other languages. -- Handle signals in picoproj and do the proper cleanup -- 2.1.4