From 6ac240a7eb92a6cfa6efaeda0c7e633f9cc5a378 Mon Sep 17 00:00:00 2001 From: patacongo Date: Thu, 24 Feb 2011 00:52:51 +0000 Subject: [PATCH] Add missing RGB type git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@3314 42af7a65-404d-4744-a932-0658087f49c3 --- TODO | 15 +++++- include/nuttx/fb.h | 113 +++++++++++++++++++++++---------------------- lib/lib_getopt.c | 24 +++++----- 3 files changed, 83 insertions(+), 69 deletions(-) diff --git a/TODO b/TODO index c3fa2ad62b..374a0ad4f3 100644 --- a/TODO +++ b/TODO @@ -11,7 +11,7 @@ NuttX TODO List (Last updated February 11, 2011) (16) Network (net/, drivers/net) (5) Network Utilities (netutils/) (1) USB (drivers/usbdev) - (4) Libraries (lib/) + (5) Libraries (lib/) (12) File system/Generic drivers (fs/, drivers/) (2) Graphics subystem (graphics/) (1) Pascal add-on (pcode/) @@ -355,6 +355,19 @@ o Libraries (lib/) Status: Open Priority: Low + Description: There is an issue with the way that getopt() handles errors that + return '?'. + + 1. Does getopt() reset its global variables after returning '?' so + that it can be re-used? That would be required to support where + the caller terminates parsing before reaching the last parameter. + 2. Or is the client expected to continue parsing after getopt() + returns '?' and parse until the final parameter? + + The current getopt() implementation only supports #2. + Status: Open + Priority: Low + o File system / Generic drivers (fs/, drivers/) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/include/nuttx/fb.h b/include/nuttx/fb.h index ab39b4c103..b6f3870830 100644 --- a/include/nuttx/fb.h +++ b/include/nuttx/fb.h @@ -1,7 +1,7 @@ /**************************************************************************** * include/nuttx/fb.h * - * Copyright (C) 2008-2010 Gregory Nutt. All rights reserved. + * Copyright (C) 2008-2011 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -67,96 +67,97 @@ #define FB_FMT_RGB1 3 /* BPP=1 */ #define FB_FMT_RGB4 4 /* BPP=4 */ -#define FB_FMT_RGB8_332 5 /* BPP=8 */ -#define FB_FMT_RGB12_444 6 /* BPP=12 */ -#define FB_FMT_RGB16_555 7 /* BPP=16 R=5, G=5, B=5 (1 unused bit) */ -#define FB_FMT_RGB16_565 8 /* BPP=16 R=6, G=6, B=5 */ -#define FB_FMT_RGB24 9 /* BPP=24 */ -#define FB_FMT_RGB32 10 /* BPP=32 */ +#define FB_FMT_RGB8 5 /* BPP=8 RGB palette index */ +#define FB_FMT_RGB8_332 6 /* BPP=8 R=3, G=3, B=2 */ +#define FB_FMT_RGB12_444 7 /* BPP=12 R=4, G=4, B=4 */ +#define FB_FMT_RGB16_555 8 /* BPP=16 R=5, G=5, B=5 (1 unused bit) */ +#define FB_FMT_RGB16_565 9 /* BPP=16 R=6, G=6, B=5 */ +#define FB_FMT_RGB24 10 /* BPP=24 */ +#define FB_FMT_RGB32 11 /* BPP=32 */ /* Run length encoded RGB */ -#define FB_FMT_RGBRLE4 11 /* BPP=4 */ -#define FB_FMT_RGBRLE8 12 /* BPP=8 */ +#define FB_FMT_RGBRLE4 12 /* BPP=4 */ +#define FB_FMT_RGBRLE8 13 /* BPP=8 */ /* Raw RGB */ -#define FB_FMT_RGBRAW 13 /* BPP=? */ +#define FB_FMT_RGBRAW 14 /* BPP=? */ /* Raw RGB with arbitrary sample packing within a pixel. Packing and precision * of R, G and B components is determined by bit masks for each. */ -#define FB_FMT_RGBBTFLD16 14 /* BPP=16 */ -#define FB_FMT_RGBBTFLD24 15 /* BPP=24 */ -#define FB_FMT_RGBBTFLD32 16 /* BPP=32 */ -#define FB_FMT_RGBA16 17 /* BPP=16 Raw RGB with alpha */ -#define FB_FMT_RGBA32 18 /* BPP=32 Raw RGB with alpha */ +#define FB_FMT_RGBBTFLD16 15 /* BPP=16 */ +#define FB_FMT_RGBBTFLD24 16 /* BPP=24 */ +#define FB_FMT_RGBBTFLD32 17 /* BPP=32 */ +#define FB_FMT_RGBA16 18 /* BPP=16 Raw RGB with alpha */ +#define FB_FMT_RGBA32 19 /* BPP=32 Raw RGB with alpha */ /* Raw RGB with a transparency field. Layout is as for stanadard RGB at 16 and * 32 bits per pixel but the msb in each pixel indicates whether the pixel is * transparent or not. */ -#define FB_FMT_RGBT16 19 /* BPP=16 */ -#define FB_FMT_RGBT32 20 /* BPP=32 */ +#define FB_FMT_RGBT16 20 /* BPP=16 */ +#define FB_FMT_RGBT32 21 /* BPP=32 */ #define FB_ISRGB(f) ((f) >= FB_FMT_RGB1) && (f) <= FB_FMT_RGBT32) /* Packed YUV Formats *******************************************************/ -#define FB_FMT_AYUV 21 /* BPP=32 Combined YUV and alpha */ -#define FB_FMT_CLJR 22 /* BPP=8 4 pixels packed into a uint32_t. +#define FB_FMT_AYUV 22 /* BPP=32 Combined YUV and alpha */ +#define FB_FMT_CLJR 23 /* BPP=8 4 pixels packed into a uint32_t. * YUV 4:1:1 with l< 8 bits per YUV sample */ -#define FB_FMT_CYUV 23 /* BPP=16 UYVY except that height is reversed */ -#define FB_FMT_IRAW 24 /* BPP=? Intel uncompressed YUV */ -#define FB_FMT_IUYV 25 /* BPP=16 Interlaced UYVY (line order +#define FB_FMT_CYUV 24 /* BPP=16 UYVY except that height is reversed */ +#define FB_FMT_IRAW 25 /* BPP=? Intel uncompressed YUV */ +#define FB_FMT_IUYV 26 /* BPP=16 Interlaced UYVY (line order * 0,2,4,.., 1,3,5...) */ -#define FB_FMT_IY41 26 /* BPP=12 Interlaced Y41P (line order +#define FB_FMT_IY41 27 /* BPP=12 Interlaced Y41P (line order * 0,2,4,.., 1,3,5...) */ -#define FB_FMT_IYU2 27 /* BPP=24 */ -#define FB_FMT_HDYC 28 /* BPP=16 UYVY except uses the BT709 color space */ -#define FB_FMT_UYVP 29 /* BPP=24? YCbCr 4:2:2, 10-bits per component in U0Y0V0Y1 order */ -#define FB_FMT_UYVY 30 /* BPP=16 YUV 4:2:2 */ +#define FB_FMT_IYU2 28 /* BPP=24 */ +#define FB_FMT_HDYC 29 /* BPP=16 UYVY except uses the BT709 color space */ +#define FB_FMT_UYVP 30 /* BPP=24? YCbCr 4:2:2, 10-bits per component in U0Y0V0Y1 order */ +#define FB_FMT_UYVY 31 /* BPP=16 YUV 4:2:2 */ #define FB_FMT_UYNV FB_FMT_UYVY /* BPP=16 */ #define FB_FMT_Y422 FB_FMT_UYVY /* BPP=16 */ -#define FB_FMT_V210 31 /* BPP=32 10-bit 4:2:2 YCrCb */ -#define FB_FMT_V422 32 /* BPP=16 Upside down version of UYVY */ -#define FB_FMT_V655 33 /* BPP=16? 16-bit YUV 4:2:2 */ -#define FB_FMT_VYUY 34 /* BPP=? ATI Packed YUV Data */ -#define FB_FMT_YUYV 35 /* BPP=16 YUV 4:2:2 */ +#define FB_FMT_V210 32 /* BPP=32 10-bit 4:2:2 YCrCb */ +#define FB_FMT_V422 33 /* BPP=16 Upside down version of UYVY */ +#define FB_FMT_V655 34 /* BPP=16? 16-bit YUV 4:2:2 */ +#define FB_FMT_VYUY 35 /* BPP=? ATI Packed YUV Data */ +#define FB_FMT_YUYV 36 /* BPP=16 YUV 4:2:2 */ #define FB_FMT_YUY2 FB_FMT_YUYV /* BPP=16 YUV 4:2:2 */ #define FB_FMT_YUNV FB_FMT_YUYV /* BPP=16 YUV 4:2:2 */ -#define FB_FMT_YVYU 36 /* BPP=16 YUV 4:2:2 */ -#define FB_FMT_Y41P 37 /* BPP=12 YUV 4:1:1 */ -#define FB_FMT_Y411 38 /* BPP=12 YUV 4:1:1 */ -#define FB_FMT_Y211 39 /* BPP=8 */ -#define FB_FMT_Y41T 40 /* BPP=12 Y41P LSB for transparency */ -#define FB_FMT_Y42T 41 /* BPP=16 UYVY LSB for transparency */ -#define FB_FMT_YUVP 42 /* BPP=24? YCbCr 4:2:2 Y0U0Y1V0 order */ +#define FB_FMT_YVYU 37 /* BPP=16 YUV 4:2:2 */ +#define FB_FMT_Y41P 38 /* BPP=12 YUV 4:1:1 */ +#define FB_FMT_Y411 39 /* BPP=12 YUV 4:1:1 */ +#define FB_FMT_Y211 40 /* BPP=8 */ +#define FB_FMT_Y41T 41 /* BPP=12 Y41P LSB for transparency */ +#define FB_FMT_Y42T 42 /* BPP=16 UYVY LSB for transparency */ +#define FB_FMT_YUVP 43 /* BPP=24? YCbCr 4:2:2 Y0U0Y1V0 order */ #define FB_ISYUVPACKED(f) ((f) >= FB_FMT_AYUV) && (f) <= FB_FMT_YUVP) /* Packed Planar YUV Formats ************************************************/ -#define FB_FMT_YVU9 43 /* BPP=9 8-bit Y followed by 8-bit 4x4 VU */ -#define FB_FMT_YUV9 44 /* BPP=9? */ -#define FB_FMT_IF09 45 /* BPP=9.5 YVU9 + 4x4 plane of delta relative to tframe. */ -#define FB_FMT_YV16 46 /* BPP=16 8-bit Y followed by 8-bit 2x1 VU */ -#define FB_FMT_YV12 47 /* BPP=12 8-bit Y followed by 8-bit 2x2 VU */ -#define FB_FMT_I420 48 /* BPP=12 8-bit Y followed by 8-bit 2x2 UV */ +#define FB_FMT_YVU9 44 /* BPP=9 8-bit Y followed by 8-bit 4x4 VU */ +#define FB_FMT_YUV9 45 /* BPP=9? */ +#define FB_FMT_IF09 46 /* BPP=9.5 YVU9 + 4x4 plane of delta relative to tframe. */ +#define FB_FMT_YV16 47 /* BPP=16 8-bit Y followed by 8-bit 2x1 VU */ +#define FB_FMT_YV12 48 /* BPP=12 8-bit Y followed by 8-bit 2x2 VU */ +#define FB_FMT_I420 49 /* BPP=12 8-bit Y followed by 8-bit 2x2 UV */ #define FB_FMT_IYUV FB_FMT_I420 /* BPP=12 */ -#define FB_FMT_NV12 49 /* BPP=12 8-bit Y followed by an interleaved 2x2 UV */ -#define FB_FMT_NV21 50 /* BPP=12 NV12 with UV reversed */ -#define FB_FMT_IMC1 51 /* BPP=12 YV12 except UV planes ame stride as Y */ -#define FB_FMT_IMC2 52 /* BPP=12 IMC1 except UV lines interleaved at half stride boundaries */ -#define FB_FMT_IMC3 53 /* BPP=12 As IMC1 except that UV swapped */ -#define FB_FMT_IMC4 54 /* BPP=12 As IMC2 except that UV swapped */ -#define FB_FMT_CLPL 55 /* BPP=12 YV12 but including a level of indirection. */ -#define FB_FMT_Y41B 56 /* BPP=12? 4:1:1 planar. */ -#define FB_FMT_Y42B 57 /* BPP=16? YUV 4:2:2 planar. */ -#define FB_FMT_CXY1 58 /* BPP=12 */ -#define FB_FMT_CXY2 59 /* BPP=16 */ +#define FB_FMT_NV12 50 /* BPP=12 8-bit Y followed by an interleaved 2x2 UV */ +#define FB_FMT_NV21 51 /* BPP=12 NV12 with UV reversed */ +#define FB_FMT_IMC1 52 /* BPP=12 YV12 except UV planes ame stride as Y */ +#define FB_FMT_IMC2 53 /* BPP=12 IMC1 except UV lines interleaved at half stride boundaries */ +#define FB_FMT_IMC3 54 /* BPP=12 As IMC1 except that UV swapped */ +#define FB_FMT_IMC4 55 /* BPP=12 As IMC2 except that UV swapped */ +#define FB_FMT_CLPL 56 /* BPP=12 YV12 but including a level of indirection. */ +#define FB_FMT_Y41B 57 /* BPP=12? 4:1:1 planar. */ +#define FB_FMT_Y42B 58 /* BPP=16? YUV 4:2:2 planar. */ +#define FB_FMT_CXY1 59 /* BPP=12 */ +#define FB_FMT_CXY2 60 /* BPP=16 */ #define FB_ISYUVPLANAR(f) ((f) >= FB_FMT_AYUV) && (f) <= FB_FMT_YUVP) #define FB_ISYUV(f) (FB_ISYUVPACKED(f) || FB_ISYUVPLANAR(f)) diff --git a/lib/lib_getopt.c b/lib/lib_getopt.c index 31ba31f661..f50c6ef1de 100644 --- a/lib/lib_getopt.c +++ b/lib/lib_getopt.c @@ -1,7 +1,7 @@ /**************************************************************************** * lib/lib_getopt.c * - * Copyright (C) 2007-2009 Gregory Nutt. All rights reserved. + * Copyright (C) 2007-2009, 2011 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -85,7 +85,7 @@ static bool g_binitialized = false; * If there are no more option characters, getopt() returns -1. Then optind * is the index in argv of the first argv-element that is not an option. * - * The 'optstring argument is a string containing the legitimate option + * The 'optstring' argument is a string containing the legitimate option * characters. If such a character is followed by a colon, this indicates * that the option requires an argument. If an argument is required for an * option so getopt() places a pointer to the following text in the same @@ -95,6 +95,11 @@ static bool g_binitialized = false; * 1. opterr is not supported and this implementation of getopt() never * printfs error messages. * 2. getopt is NOT threadsafe! + * 3. This version of getopt() does not reset global variables until + * -1 is returned. As a result, your command line parsing loops + * must call getopt() repeatedly and continue to parse if other + * errors are returned ('?' or ':') until getopt() finally returns -1. + * (You can also set optind to -1 to force a reset). * * Return: If an option was successfully found, then getopt() returns the * option character. If all command-line options have been parsed, then @@ -162,9 +167,6 @@ int getopt(int argc, FAR char *const argv[], FAR const char *optstring) /* There are no more arguments, we are finished */ g_binitialized = false; - - /* Return -1 with optind == all of the arguments */ - return ERROR; } @@ -176,11 +178,7 @@ int getopt(int argc, FAR char *const argv[], FAR const char *optstring) { /* The argument does not start with '-', we are finished */ - g_optptr = NULL; g_binitialized = false; - - /* Return the -1 with optind set to the non-option argument */ - return ERROR; } @@ -226,13 +224,15 @@ int getopt(int argc, FAR char *const argv[], FAR const char *optstring) if (optchar[1] != ':') { - /* No, just return the character that we found */ + /* No, no arguments. Just return the character that we found */ g_optptr++; return *optchar; } - /* Yes. Is the required argument after the command in this same argument? */ + /* Yes, it has a required argument. Is the required argument + * immediately after the command in this same argument? + */ if (g_optptr[1] != '\0') { @@ -264,6 +264,6 @@ int getopt(int argc, FAR char *const argv[], FAR const char *optstring) return noarg_ret; } - optind = 1; + g_binitialized = false; return ERROR; }