[Armadeus-commitlog] armadeus branch, master, updated. release-3.2-308-gb7f5889
Brought to you by:
sszy
|
From: Julien B a. A. <ar...@us...> - 2010-04-21 12:32:55
|
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "armadeus".
The branch, master has been updated
via b7f5889a3c6740ac887a61e230db1f4c0f491bc5 (commit)
via b17417d3a0bea2c9e2932203bf168c385d284a13 (commit)
via 9b27c4f87007c68b48fac607405fe7e656fe1c55 (commit)
via f99d91472081d282231531a71bb0f35825a1c634 (commit)
from 94f14a6d13d63a9d72d22acddf0861c173a22d14 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit b7f5889a3c6740ac887a61e230db1f4c0f491bc5
Author: Julien Boibessot <jul...@ar...>
Date: Wed Apr 21 14:32:07 2010 +0200
Indentation
commit b17417d3a0bea2c9e2932203bf168c385d284a13
Author: Julien Boibessot <jul...@ar...>
Date: Wed Apr 21 14:31:00 2010 +0200
[DEMOS] Capture: add RGR565 support (default format) + the possibility to choose screen and picture sizes
commit 9b27c4f87007c68b48fac607405fe7e656fe1c55
Author: Julien Boibessot <jul...@ar...>
Date: Wed Apr 21 14:29:59 2010 +0200
[DEMOS] Capture: link with libpthread otherwise runtime crash may occur
commit f99d91472081d282231531a71bb0f35825a1c634
Author: Julien Boibessot <jul...@ar...>
Date: Wed Apr 21 14:29:00 2010 +0200
[DEMOS] Capture: improve doc
-----------------------------------------------------------------------
Summary of changes:
target/demos/backlight_control/backlight.c | 152 +++++++++++++--------------
target/demos/camera/capture/.gitignore | 1 +
target/demos/camera/capture/Makefile | 2 +-
target/demos/camera/capture/README | 5 +
target/demos/camera/capture/capture.c | 111 ++++++++++++++++-----
target/demos/test_lcd/test_lcd.c | 3 +-
6 files changed, 166 insertions(+), 108 deletions(-)
create mode 100644 target/demos/camera/capture/.gitignore
create mode 100644 target/demos/camera/capture/README
diff --git a/target/demos/backlight_control/backlight.c b/target/demos/backlight_control/backlight.c
index 197cd70..36e3da8 100644
--- a/target/demos/backlight_control/backlight.c
+++ b/target/demos/backlight_control/backlight.c
@@ -61,37 +61,35 @@ static int loadImages()
{
int result = 0;
- full_end = SDL_LoadBMP( DEFAULT_DATA_DIR "full_end.bmp" );
- full = SDL_LoadBMP( DEFAULT_DATA_DIR "full.bmp" );
- cursor = SDL_LoadBMP( DEFAULT_DATA_DIR "cursor.bmp" );
- empty = SDL_LoadBMP( DEFAULT_DATA_DIR "empty.bmp" );
- empty_end = SDL_LoadBMP( DEFAULT_DATA_DIR "empty_end.bmp" );
-
- // Check if we got all images
- if( full_end == NULL || full == NULL || cursor == NULL || empty == NULL || empty_end == NULL )
- {
+ full_end = SDL_LoadBMP(DEFAULT_DATA_DIR "full_end.bmp");
+ full = SDL_LoadBMP(DEFAULT_DATA_DIR "full.bmp");
+ cursor = SDL_LoadBMP(DEFAULT_DATA_DIR "cursor.bmp");
+ empty = SDL_LoadBMP(DEFAULT_DATA_DIR "empty.bmp");
+ empty_end = SDL_LoadBMP(DEFAULT_DATA_DIR "empty_end.bmp");
+
+ /* Check if we got all images */
+ if (full_end == NULL || full == NULL || cursor == NULL || empty == NULL || empty_end == NULL) {
printf("Unable to load image files !\n");
result = -1;
} else {
//SDL_SetAlpha( image, 0/*SDL_SRCALPHA*/, SDL_ALPHA_TRANSPARENT );
- if( SDL_SetColorKey( cursor, SDL_SRCCOLORKEY, SDL_MapRGB(cursor->format, 0xFF, 0xFF, 0xFF) ) )
- {
+ if (SDL_SetColorKey(cursor, SDL_SRCCOLORKEY, SDL_MapRGB(cursor->format, 0xFF, 0xFF, 0xFF))) {
printf("Error while setting transparent color\n");
}
}
- return(result);
+ return result;
}
//
static void freeRessources()
{
- SDL_FreeSurface( screen );
- SDL_FreeSurface( full_end );
- SDL_FreeSurface( full );
- SDL_FreeSurface( cursor );
- SDL_FreeSurface( empty );
- SDL_FreeSurface( empty_end );
+ SDL_FreeSurface(screen);
+ SDL_FreeSurface(full_end);
+ SDL_FreeSurface(full);
+ SDL_FreeSurface(cursor);
+ SDL_FreeSurface(empty);
+ SDL_FreeSurface(empty_end);
}
//
@@ -108,84 +106,84 @@ void drawBackground()
{
SDL_Rect dest;
dest.x = 0; dest.y = 0; dest.w = SCREEN_WIDTH; dest.h = SCREEN_HEIGHT;
- // Fill background
- SDL_FillRect( screen, &dest, SDL_MapRGB( screen->format, 0xFF, 0xFF, 0xFF ) );
+ /* Fill background */
+ SDL_FillRect(screen, &dest, SDL_MapRGB(screen->format, 0xFF, 0xFF, 0xFF));
}
//
-static int paddXPos( int xpos )
+static int paddXPos(int xpos)
{
- int x=0;
+ int x = 0;
- if( xpos <= BAR_MIN_XPOSITION ) {
+ if (xpos <= BAR_MIN_XPOSITION) {
x = BAR_MIN_XPOSITION;
- } else if ( xpos >= BAR_MAX_XPOSITION ) {
+ } else if (xpos >= BAR_MAX_XPOSITION) {
x = BAR_MAX_XPOSITION;
} else {
x = xpos;
}
- return( x );
+ return x;
}
//
-static void drawBar( int xpos )
+static void drawBar(int xpos)
{
- int i=BAR_MIN_XPOSITION;
+ int i = BAR_MIN_XPOSITION;
- if( xpos <= BAR_MIN_XPOSITION ) {
+ if (xpos <= BAR_MIN_XPOSITION) {
xpos = BAR_MIN_XPOSITION;
- } else if ( xpos >= BAR_MAX_XPOSITION ) {
+ } else if (xpos >= BAR_MAX_XPOSITION) {
xpos = BAR_MAX_XPOSITION;
}
- drawImage( full_end, i, BAR_YPOSITION );
+ drawImage(full_end, i, BAR_YPOSITION);
i+=5;
- for( ; i<=xpos; i+=5 ) {
- drawImage( full, i, BAR_YPOSITION );
+ for ( ; i<=xpos; i+=5) {
+ drawImage(full, i, BAR_YPOSITION);
}
- for( ; i<=BAR_MAX_XPOSITION; i+=5 ) {
- drawImage( empty, i, BAR_YPOSITION );
+ for ( ; i<=BAR_MAX_XPOSITION; i+=5) {
+ drawImage(empty, i, BAR_YPOSITION);
}
- drawImage( empty_end, i, BAR_YPOSITION );
+ drawImage(empty_end, i, BAR_YPOSITION);
}
//
-static unsigned char calculateBacklight( int xpos )
+static unsigned char calculateBacklight(int xpos)
{
int x = 0;
- unsigned char backlight = 0; // 0-100 %
+ unsigned char backlight = 0; /* 0-100 % */
- x = paddXPos( xpos );
+ x = paddXPos(xpos);
backlight = (unsigned char) (((x - BAR_MIN_XPOSITION)*100) / BAR_WIDTH);
- return( backlight );
+ return backlight;
}
//
-static void drawCursor( int xpos )
+static void drawCursor(int xpos)
{
- int x=0;
+ int x = 0;
- x = paddXPos( xpos );
- drawImage( cursor, x, BAR_YPOSITION-5 );
+ x = paddXPos(xpos);
+ drawImage(cursor, x, BAR_YPOSITION-5);
}
//
-void updateCursor( int xpos )
+void updateCursor(int xpos)
{
drawBackground();
- drawBar( xpos );
- drawCursor(xpos );
- SDL_Flip( screen );
+ drawBar(xpos);
+ drawCursor(xpos);
+ SDL_Flip(screen);
}
-void cleanup( void )
+void cleanup(void)
{
- // Cleanup what we used
+ /* Cleanup what we used */
releaseBacklightControl();
freeRessources();
SDL_Quit();
@@ -199,55 +197,53 @@ int main(int argc, char *argv[])
Uint8* keys;
int cursorPos = 0;
- // Initialize SDL
- if( SDL_Init( SDL_INIT_VIDEO | SDL_INIT_TIMER /*| SDL_INIT_EVENTTHREAD |SDL_INIT_NOPARACHUTE*/) < 0 )
- {
+ /* Initialize SDL */
+ if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER /*| SDL_INIT_EVENTTHREAD |SDL_INIT_NOPARACHUTE*/) < 0) {
fprintf(stderr, "Unable to init SDL: %s\n", SDL_GetError());
exit(1);
}
- // Ask SDL to cleanup when exiting
+ /* Ask SDL to cleanup when exiting */
atexit(cleanup);
- // Get a screen to display our game
- screen=SDL_SetVideoMode( SCREEN_WIDTH, SCREEN_HEIGHT, 16, 0/*SDL_HWPALETTE*//*SDL_HWSURFACE|| SDL_DOUBLEBUF*/ );
- if( screen == NULL )
- {
+ /* Get a screen to display our GUI */
+ screen = SDL_SetVideoMode(SCREEN_WIDTH, SCREEN_HEIGHT, 16, 0/*SDL_HWPALETTE*//*SDL_HWSURFACE|| SDL_DOUBLEBUF*/);
+ if (screen == NULL) {
fprintf(stderr, "Unable to set %dx%dvideo mode: %s\n", SCREEN_WIDTH, SCREEN_HEIGHT, SDL_GetError());
exit(1);
}
- // Load our graphics
- if( loadImages() )
- {
- return(1);
+ /* Load our graphics */
+ if (loadImages()) {
+ return 1;
}
drawBackground();
- // Initialize Backlight control
- if( initBacklightControl() )
- {
+ /* Initialize Backlight control */
+ if (initBacklightControl()) {
printf("Unable to find Backlight control on your system -> won't be activated\n");
}
- updateCursor( (getBrightness() * BAR_WIDTH / 100) + BAR_MIN_XPOSITION );
+ updateCursor((getBrightness() * BAR_WIDTH / 100) + BAR_MIN_XPOSITION);
int done=0, move=0;
- // Hide mouse
+ /* Hide mouse */
SDL_ShowCursor(0);
- // Main loop
- while(done == 0)
+ /* Main loop */
+ while (done == 0)
{
SDL_Event event;
- // Wait for SDL events
- while ( SDL_PollEvent(&event) )
+ /* Wait for SDL events */
+ while (SDL_PollEvent(&event))
{
cursorPos = 0;
- switch( event.type )
+ switch (event.type)
{
case SDL_QUIT: { done = 1; break; }
case SDL_KEYDOWN:
{
- if ( event.key.keysym.sym == SDLK_ESCAPE ) { done = 1; }
+ if (event.key.keysym.sym == SDLK_ESCAPE) {
+ done = 1;
+ }
break;
}
case SDL_MOUSEBUTTONDOWN:
@@ -261,7 +257,7 @@ int main(int argc, char *argv[])
case SDL_MOUSEMOTION:
{
- if( move == 1 ) {
+ if (move == 1) {
debug("Current mouse position is: (%d, %d)\n", event.motion.x, event.motion.y);
cursorPos = event.motion.x;
}
@@ -270,12 +266,10 @@ int main(int argc, char *argv[])
}
}
- if( cursorPos != 0 && move == 1 ) {
- //
- setBrightness( calculateBacklight( cursorPos ) );
-
- // Update screen
- updateCursor( cursorPos );
+ if (cursorPos != 0 && move == 1) {
+ setBrightness(calculateBacklight(cursorPos));
+ /* Update screen */
+ updateCursor(cursorPos);
}
SDL_Delay(50);
diff --git a/target/demos/camera/capture/.gitignore b/target/demos/camera/capture/.gitignore
new file mode 100644
index 0000000..c727a35
--- /dev/null
+++ b/target/demos/camera/capture/.gitignore
@@ -0,0 +1 @@
+capture
diff --git a/target/demos/camera/capture/Makefile b/target/demos/camera/capture/Makefile
index 7cd81a8..4271506 100644
--- a/target/demos/camera/capture/Makefile
+++ b/target/demos/camera/capture/Makefile
@@ -1,5 +1,5 @@
CFLAGS=-Wall
-LDFLAGS= -lSDL
+LDFLAGS= -lSDL -lpthread
ifeq ($(PREFIX),)
# Host
CC=gcc
diff --git a/target/demos/camera/capture/README b/target/demos/camera/capture/README
new file mode 100644
index 0000000..53efb9c
--- /dev/null
+++ b/target/demos/camera/capture/README
@@ -0,0 +1,5 @@
+Compile me:
+* native:
+ $ make
+* cross-compilation:
+ $ make CC=/.../.../arm-linux-gcc
diff --git a/target/demos/camera/capture/capture.c b/target/demos/camera/capture/capture.c
index 9de29df..53726a7 100644
--- a/target/demos/camera/capture/capture.c
+++ b/target/demos/camera/capture/capture.c
@@ -77,10 +77,8 @@ struct camera mycamera;
static void errno_exit(const char *s)
{
- fprintf (stderr, "%s error %d, %s\n",
- s, errno, strerror (errno));
-
- exit (EXIT_FAILURE);
+ fprintf(stderr, "%s error %d, %s\n", s, errno, strerror (errno));
+ exit(EXIT_FAILURE);
}
static int xioctl(int fd, int request, void *arg)
@@ -211,7 +209,9 @@ static void process_image(/*const */void *pCaptured)
} else if (mycamera.pixelformat == V4L2_PIX_FMT_YUV420) {
yuv420_to_rgb565(pCaptured, mycamera.sizeimage, image->pixels);
} else {
- printf("Unknown image format\n");
+ if (mycamera.pixelformat != V4L2_PIX_FMT_RGB565) {
+ printf("Unknown image format\n");
+ }
simple_copy(pCaptured, mycamera.sizeimage, image->pixels);
}
@@ -592,6 +592,22 @@ static Uint32 get_a_supported_pix_fmt(void)
struct v4l2_fmtdesc fmtdesc;
int i;
+ /* First check if a LCD native format is available (-> no CSC) */
+ for (i = 0;; i++) {
+ CLEAR(fmtdesc);
+ fmtdesc.index = i;
+ fmtdesc.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
+ if (-1 == ioctl(fd, VIDIOC_ENUM_FMT, &fmtdesc))
+ break;
+
+ if (fmtdesc.pixelformat == V4L2_PIX_FMT_RGB565) {
+ fprintf(stdout, "Using img format (%d 0x%08x): ", i, fmtdesc.pixelformat);
+ fprintf(stdout, "RGB565\n");
+ return fmtdesc.pixelformat;
+ }
+ }
+
+ /* If no RGB565, then default to YUV422 or YUV420 */
for (i = 0;; i++) {
CLEAR(fmtdesc);
fmtdesc.index = i;
@@ -612,7 +628,7 @@ static Uint32 get_a_supported_pix_fmt(void)
return 0;
}
-static void init_device(void)
+static void init_device(unsigned int capt_width, unsigned int capt_height)
{
struct v4l2_capability cap;
struct v4l2_cropcap cropcap;
@@ -691,14 +707,15 @@ static void init_device(void)
}
fmt.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
- fmt.fmt.pix.width = CAM_WIDTH;
- fmt.fmt.pix.height = CAM_HEIGHT;
+ fmt.fmt.pix.width = capt_width;
+ fmt.fmt.pix.height = capt_height;
fmt.fmt.pix.field = V4L2_FIELD_INTERLACED;
- if (-1 == xioctl (fd, VIDIOC_S_FMT, &fmt))
- errno_exit ("VIDIOC_S_FMT");
+ if (-1 == xioctl(fd, VIDIOC_S_FMT, &fmt))
+ errno_exit("VIDIOC_S_FMT");
/* Note VIDIOC_S_FMT may change width and height. */
+ fprintf(stdout, "Camera picture: %dx%d\n", fmt.fmt.pix.width, fmt.fmt.pix.height);
/* Buggy driver paranoia. */
min = fmt.fmt.pix.width * 2;
@@ -771,23 +788,37 @@ static void usage(FILE *fp, int argc, char **argv)
"-m | --mmap Use memory mapped buffers\n"
"-r | --read Use read() calls\n"
"-u | --userp Use application allocated buffers\n"
+ "--width W Use W as screen width (instead of %d)\n"
+ "--height H Use H as screen height (instead of %d)\n"
+ "--camwidth W Use W as camera picture width (instead of %d)\n"
+ "--camheight H Use H as camera picture height (instead of %d)\n"
"",
- argv[0]);
+ argv[0], SCREEN_WIDTH, SCREEN_HEIGHT, CAM_WIDTH, CAM_HEIGHT);
}
-static const char short_options [] = "d:hmru";
+static const char short_options [] = "d:hmruwt";
static const struct option long_options [] = {
- { "device", required_argument, NULL, 'd' },
- { "help", no_argument, NULL, 'h' },
- { "mmap", no_argument, NULL, 'm' },
- { "read", no_argument, NULL, 'r' },
- { "userp", no_argument, NULL, 'u' },
- { 0, 0, 0, 0 }
+ { "device", required_argument, NULL, 'd' },
+ { "help", no_argument, NULL, 'h' },
+ { "mmap", no_argument, NULL, 'm' },
+ { "read", no_argument, NULL, 'r' },
+ { "userp", no_argument, NULL, 'u' },
+ { "width", required_argument, NULL, 'w' },
+ { "height", required_argument, NULL, 't' },
+ { "camwidth", required_argument, NULL, 'y' },
+ { "camheight", required_argument, NULL, 'z' },
+ { 0, 0, 0, 0 }
};
int main(int argc, char **argv)
{
+ int ret = EXIT_SUCCESS;
+ unsigned int width = SCREEN_WIDTH;
+ unsigned int height = SCREEN_HEIGHT;
+ unsigned int camwidth = CAM_WIDTH;
+ unsigned int camheight = CAM_HEIGHT;
+
dev_name = "/dev/video0";
atexit(SDL_Quit);
@@ -812,7 +843,7 @@ int main(int argc, char **argv)
case 'h':
usage(stdout, argc, argv);
- exit (EXIT_SUCCESS);
+ exit(EXIT_SUCCESS);
case 'm':
io = IO_METHOD_MMAP;
@@ -826,17 +857,44 @@ int main(int argc, char **argv)
io = IO_METHOD_USERPTR;
break;
+ case 'w':
+ width = atoi(optarg);
+ break;
+
+ case 't':
+ height = atoi(optarg);
+ break;
+
+ case 'y':
+ camwidth = atoi(optarg);
+ break;
+
+ case 'z':
+ camheight = atoi(optarg);
+ break;
+
default:
usage(stderr, argc, argv);
exit(EXIT_FAILURE);
}
}
- open_device();
- init_device();
+ open_device();
+ camwidth = camwidth > width ? width : camwidth;
+ camheight = camheight > height ? height : height;
+ init_device(camwidth, camheight);
SDL_Init(SDL_INIT_VIDEO);
- screen = SDL_SetVideoMode(SCREEN_WIDTH, SCREEN_HEIGHT, 16, (SDL_HWSURFACE));
+ screen = SDL_SetVideoMode(width, height, 16, (SDL_HWSURFACE));
+ if (screen) {
+ printf("Video mode: %dx%dx%d\n", screen->w, screen->h,
+ screen->format->BitsPerPixel);
+ } else {
+ printf("Unable to set %dx%d video mode: %s\n", SCREEN_WIDTH, SCREEN_HEIGHT, SDL_GetError());
+ ret = EXIT_FAILURE;
+ goto the_end;
+ }
+
image = SDL_CreateRGBSurface(/*SDL_HWSURFACE*/0, mycamera.width, mycamera.height, 16, 0, 0, 0, 0);
// printf("image fmt: RGB%d%d%d\n", image->format->Rshift, image->format->Gshift, image->format->Bshift);
@@ -844,10 +902,11 @@ int main(int argc, char **argv)
mainloop();
stop_capturing();
- uninit_device();
- close_device();
+the_end:
+ uninit_device();
+ close_device();
- exit(EXIT_SUCCESS);
+ exit(ret);
- return 0;
+ return 0;
}
diff --git a/target/demos/test_lcd/test_lcd.c b/target/demos/test_lcd/test_lcd.c
index 6e82467..7ca7b9a 100644
--- a/target/demos/test_lcd/test_lcd.c
+++ b/target/demos/test_lcd/test_lcd.c
@@ -65,8 +65,7 @@ int main(int argc, char *argv[])
int i, height, width;
/* Initialize SDL */
- if( SDL_Init( SDL_INIT_VIDEO | SDL_INIT_TIMER /*| SDL_INIT_EVENTTHREAD |SDL_INIT_NOPARACHUTE*/) < 0 )
- {
+ if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER /*| SDL_INIT_EVENTTHREAD |SDL_INIT_NOPARACHUTE*/) < 0) {
fprintf(stderr, "Unable to init SDL: %s\n", SDL_GetError());
exit(1);
}
hooks/post-receive
--
armadeus
|