[oe-commits] org.oe.dev packages/mplayer/mplayer_0.0+1.0rc1.bb : update the vo_pxa driver from Tim Chick
xora commit
openembedded-commits at lists.openembedded.org
Thu Mar 15 12:49:18 UTC 2007
packages/mplayer/mplayer_0.0+1.0rc1.bb : update the vo_pxa driver from Tim Chick
Author: xora at openembedded.org
Branch: org.openembedded.dev
Revision: 4c2e0c714dee3487dfde36966ee922357cfb407d
ViewMTN: http://monotone.openembedded.org/revision.psp?id=4c2e0c714dee3487dfde36966ee922357cfb407d
Files:
1
packages/mplayer/files/vo_pxa.c
packages/mplayer/files/vo_pxa.h
packages/mplayer/mplayer_0.0+1.0rc1.bb
Diffs:
#
# mt diff -r6a3b981cd09643c90b1f45b77d55ea346170dac9 -r4c2e0c714dee3487dfde36966ee922357cfb407d
#
#
#
# patch "packages/mplayer/files/vo_pxa.c"
# from [232a0a09474adf675f6ecdcee472bfce70d30c1c]
# to [7de9b892140276437cc91b095dd41573f4d33212]
#
# patch "packages/mplayer/files/vo_pxa.h"
# from [22815b5f5c0a47a2ada91a716afbe96504109c11]
# to [87d190c0b4de259fea1a8214d2856565e92859ae]
#
# patch "packages/mplayer/mplayer_0.0+1.0rc1.bb"
# from [1b3ec4ef1095700adad0828eb5af96d0b3601163]
# to [f8d1864ec3f3e06021a6bf9d668fc05c35fdda48]
#
============================================================
--- packages/mplayer/files/vo_pxa.c 232a0a09474adf675f6ecdcee472bfce70d30c1c
+++ packages/mplayer/files/vo_pxa.c 7de9b892140276437cc91b095dd41573f4d33212
@@ -7,6 +7,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <errno.h>
#include "config.h"
#include "video_out.h"
@@ -62,7 +63,8 @@ static int preinit(const char *vo_subdev
if( rc == -1 )
{
- mp_msg( MSGT_VO, MSGL_ERR, "vo_pxa: FBIOGET_VSCREENINFO line %d failed\n", __LINE__ );
+ mp_msg( MSGT_VO, MSGL_ERR, "vo_pxa: FBIOGET_VSCREENINFO preinit base_fd failed %d\n",
+ errno );
/* If this failed, close down the FD so we don't try to set this again */
close( priv->base_fd );
@@ -94,9 +96,9 @@ static int config(uint32_t src_width, ui
{
pxa_priv_t *priv = &st_pxa_priv;
int rc;
+ int i;
- mp_msg(MSGT_VO, MSGL_V, "vo_pxa: config() was called\n");
- mp_msg(MSGT_VO, MSGL_V, "vo_pxa: src_width:%d, src_height:%d, dst_width:%d, dst_height:%d\n",
+ mp_msg(MSGT_VO, MSGL_V, "vo_pxa: config() src_width:%d, src_height:%d, dst_width:%d, dst_height:%d\n",
src_width, src_height, dst_width, dst_height);
/* Check format */
@@ -129,21 +131,23 @@ static int config(uint32_t src_width, ui
if( rc == -1 )
{
- mp_msg( MSGT_VO, MSGL_ERR, "vo_pxa: Set of base fb failed\n");
+ mp_msg( MSGT_VO, MSGL_ERR, "vo_pxa: config() Set FBIOPUT_VSCREENINFO on base_fd failed %d\n",
+ errno );
priv->vm = 0;
goto err_out;
}
+
+ /* We need this sleep, to make the change in resolution actually happen, before we open the overlay */
+ sleep(1);
}
- /* We need these sleeps, to make the change in resolution actually happen, before we open the overlay */
- sleep(2);
/* Open up the overlay fbdev */
priv->fd = open( "/dev/fb2", O_RDWR );
if( priv->fd < 0 )
{
- mp_msg( MSGT_VO, MSGL_ERR, "vo_pxa: Could not open framebuffer device\n");
+ mp_msg( MSGT_VO, MSGL_ERR, "vo_pxa: Could not open /dev/fb2: %d\n", errno );
goto err_out;
}
@@ -152,13 +156,40 @@ static int config(uint32_t src_width, ui
if( rc == -1 )
{
- mp_msg( MSGT_VO, MSGL_ERR, "vo_pxa: FBIOGET_VSCREENINFO line %d failed\n", __LINE__ );
+ mp_msg( MSGT_VO, MSGL_ERR, "vo_pxa: config() FBIOGET_VSCREENINFO from fd failed %d\n",
+ errno );
goto err_out;
}
+ /* Store away the source dimensions, so we can place in centre of screen later in vm mode */
+ priv->src_width = src_width;
+ priv->src_height = src_height;
+
/* Set up the buffer */
- priv->my_fb_var.xres = src_width;
- priv->my_fb_var.yres = src_height;
+ if( priv->vm )
+ {
+ /* Ignore size, as the rest of the screen is toast. Use max size */
+ priv->my_fb_var.xres = 240;
+ priv->my_fb_var.yres = 320;
+
+ /* Do we need to rotate? */
+ if( priv->src_width > priv->src_height )
+ {
+ /* Yes */
+ priv->rotate = 1;
+ }
+
+ priv->width = 240;
+ priv->height = 320;
+ }
+ else
+ {
+ priv->my_fb_var.xres = src_width;
+ priv->my_fb_var.yres = src_height;
+ priv->width = src_width;
+ priv->height = src_height;
+ }
+
priv->my_fb_var.nonstd = ( 4 << 20) /* Format YV12 */
| ( 0 << 0) /* x position */
| ( 0 << 10); /* y position */
@@ -171,7 +202,8 @@ static int config(uint32_t src_width, ui
if( rc == -1 )
{
- mp_msg( MSGT_VO, MSGL_ERR, "vo_pxa: FBIOPUT_VSCREENINFO line %d failed\n", __LINE__ );
+ mp_msg( MSGT_VO, MSGL_ERR, "vo_pxa: config() FBIOPUT_VSCREENINFO to fd failed: %d\n",
+ errno );
goto err_out;
}
@@ -180,7 +212,8 @@ static int config(uint32_t src_width, ui
if( rc == -1 )
{
- mp_msg( MSGT_VO, MSGL_ERR, "vo_pxa: FBIOGET_FSCREENINFO line %d failed\n", __LINE__ );
+ mp_msg( MSGT_VO, MSGL_ERR, "vo_pxa: config() FBIOGET_FSCREENINFO from fd failed: %d\n",
+ errno );
goto err_out;
}
@@ -191,7 +224,7 @@ static int config(uint32_t src_width, ui
if( priv->fb_mem_base == MAP_FAILED )
{
- mp_msg( MSGT_VO, MSGL_ERR, "vo_pxa: mmap buffer failed\n" );
+ mp_msg( MSGT_VO, MSGL_ERR, "vo_pxa: mmap fd buffer failed: %d\n", errno );
goto err_out;
}
@@ -200,12 +233,79 @@ static int config(uint32_t src_width, ui
if( rc == -1 )
{
- mp_msg( MSGT_VO, MSGL_ERR, "vo_pxa: FBIOGET_VSCREENINFO line %d failed\n", __LINE__ );
+ mp_msg( MSGT_VO, MSGL_ERR, "vo_pxa: config() FBIOGET_VSCREENINFO from fd (2) failed %d\n",
+ errno );
goto err_out;
}
+ /* Fill the overlay with black */
+ memset( priv->fb_mem_base + priv->my_fb_var.red.offset, 16, priv->my_fb_var.red.length );
+ memset( priv->fb_mem_base + priv->my_fb_var.green.offset, 128, priv->my_fb_var.green.length );
+ memset( priv->fb_mem_base + priv->my_fb_var.blue.offset, 128, priv->my_fb_var.blue.length );
+
+ /* Now open the OSD overlay - overlay 1, and fill with transparent */
+ sleep( 1 );
+
+ priv->overlay_fd = open( "/dev/fb1", O_RDWR );
+
+ if( priv->overlay_fd < 0 )
+ {
+ mp_msg( MSGT_VO, MSGL_ERR, "vo_pxa: Could not open /dev/fb1: %d\n", errno );
+ goto err_out;
+ }
+
+ /* Read in fb var data */
+ rc = ioctl( priv->overlay_fd, FBIOGET_VSCREENINFO, &(priv->osd_fb_var) );
+
+ if( rc == -1 )
+ {
+ mp_msg( MSGT_VO, MSGL_ERR, "vo_pxa: config() FBIOGET_VSCREENINFO from overlay_fd failed; %d\n",
+ errno );
+ goto err_out;
+ }
+
+ priv->osd_fb_var.xres = priv->width;
+ priv->osd_fb_var.yres = priv->height;
+ priv->osd_fb_var.nonstd = ( 0 << 0) /* x position */
+ | ( 0 << 10); /* y position */
+ /* Use 15 bit mode, with top bit transparency */
+ priv->osd_fb_var.bits_per_pixel = 16;
+
+ rc = ioctl( priv->overlay_fd, FBIOPUT_VSCREENINFO, &(priv->osd_fb_var) );
+
+ if( rc == -1 )
+ {
+ mp_msg( MSGT_VO, MSGL_ERR, "vo_pxa: config() FBIOPUT_VSCREENINFO to overlay_fd failed: %d\n",
+ errno );
+ goto err_out;
+ }
+
+ /* Next get the fixed fbvars, so we can mmap the data */
+ rc = ioctl( priv->overlay_fd, FBIOGET_FSCREENINFO, &(priv->osd_fb_fix) );
+
+ if( rc == -1 )
+ {
+ mp_msg( MSGT_VO, MSGL_ERR, "vo_pxa: config() FBIOGET_FSCREENINFO from overlay_fd failed %d\n",
+ errno );
+ goto err_out;
+ }
+
+ priv->osd_mem_base = mmap( NULL, priv->osd_fb_fix.smem_len, (PROT_READ | PROT_WRITE ),
+ MAP_SHARED,
+ priv->overlay_fd,
+ 0 );
+
+ if( priv->osd_mem_base == MAP_FAILED )
+ {
+ mp_msg( MSGT_VO, MSGL_ERR, "vo_pxa: mmap osd_mem_base failed: %d\n", errno );
+ goto err_out;
+ }
+
+ /* Fill the overlay with transparent */
+ vo_pxa_clear_osd( priv->osd_mem_base, priv->osd_fb_fix.smem_len );
+
/* We are good to go! */
- mp_msg( MSGT_VO, MSGL_V, "vo_pxa: FOpened screen %d x %d fourcc %s\n",
+ mp_msg( MSGT_VO, MSGL_V, "vo_pxa: Opened video overlay %d x %d fourcc %s\n",
priv->my_fb_var.xres,
priv->my_fb_var.yres,
vo_format_name(format) );
@@ -213,18 +313,8 @@ static int config(uint32_t src_width, ui
return 0;
err_out:
-
- if( priv->fb_mem_base != MAP_FAILED )
- {
- munmap( priv->fb_mem_base, priv->my_fb_fix.smem_len );
- priv->fb_mem_base = MAP_FAILED;
- }
-
- if( priv->fd >= 0 )
- {
- close( priv->fd );
- priv->fd = -1;
- }
+
+ /* Don't do anything here for the moment */
return -1;
}
@@ -238,6 +328,8 @@ static int control(uint32_t request, voi
****************************************************************************/
static int control(uint32_t request, void *data, ...)
{
+ mp_msg(MSGT_VO, MSGL_V, "vo_pxa: control %08x\n", request );
+
switch( request )
{
case VOCTRL_QUERY_FORMAT:
@@ -261,7 +353,7 @@ int draw_frame(uint8_t *src[])
int draw_frame(uint8_t *src[])
{
/* This is not implimented */
- mp_msg(MSGT_VO, MSGL_V, "vo_pxa: dummy draw_frame() was called\n");
+ mp_msg(MSGT_VO, MSGL_ERR, "vo_pxa: dummy draw_frame() was called\n");
return -1;
}
@@ -281,79 +373,291 @@ int draw_slice(uint8_t *src[], int strid
int draw_slice(uint8_t *src[], int stride[], int w,int h, int x,int y)
{
pxa_priv_t *priv = &st_pxa_priv;
- uint8_t *my_src;
- uint8_t *dest;
- size_t length;
- int i;
/* This routine is only display routine actually implimented */
- mp_msg(MSGT_VO, MSGL_V, "vo_pxa: draw_slice() was called\n");
+ mp_msg(MSGT_VO, MSGL_V, "vo_pxa: draw_slice() w %d h %d x %d y %d stride %d %d %d\n",
+ w, h, x, y, stride[0], stride[1], stride[2] );
/* It would be faster to check if source and dest have same geometry and copy
* whole block
* For the moment we just copy a line at a time
*/
- /* Limit area written to */
- if( x >= priv->my_fb_fix.line_length )
+ /* In vm mode rotate if wider than long */
+ if( priv->vm )
{
- return 0;
- }
+ /* Do we nee to rotate? */
+ if( priv->rotate )
+ {
+ /* Yes, rotated version */
+ int dst_x_offset = 0;
+ int dst_y_offset = 0;
+ int src_x_offset = 0;
+ int src_y_offset = 0;
+
+ /* Figure out dst offset */
+ if( priv->src_width < 320 )
+ {
+ dst_x_offset = ( ( 320 - priv->src_width ) / 2 );
+ /* Make it a multiple of 16 */
+ dst_x_offset &= ~(0xf);
+ }
+
+ if( priv->src_height < 240 )
+ {
+ dst_y_offset = ( ( 240 - priv->src_height ) / 2 );
+ /* Make it a multiple of 16 */
+ dst_y_offset &= ~(0xf);
+ }
+
+ dst_x_offset += x;
+ dst_y_offset += y;
+
+ if( ( dst_x_offset >= 320 ) || ( dst_y_offset >= 240 ) )
+ {
+ /* Nothing to do - drawing off the screen! */
+ return( 0 );
+ }
+
+ /* Limit to drawable area */
+ if( ( w + dst_x_offset ) > 320 )
+ {
+ w = ( 320 - dst_x_offset );
+ }
+
+ if( ( h + dst_y_offset ) > 240 )
+ {
+ h = ( 240 - dst_y_offset );
+ }
+
+ /* And source offset */
+ if( priv->src_width > 320 )
+ {
+ src_x_offset = ( ( priv->src_width - 320 ) / 2 );
+ /* Make it a multiple of 16 */
+ src_x_offset &= ~(0xf);
+ }
+
+ if( priv->src_height > 240 )
+ {
+ src_y_offset = ( ( priv->src_height - 240 ) / 2 );
+ /* Make it a multiple of 16 */
+ src_y_offset &= ~(0xf);
+ }
+
+
+ /* Y first */
+ vo_pxa_copy_and_rotate( src[0] + src_x_offset + (src_y_offset * stride[0]), stride[0],
+ priv->fb_mem_base + priv->my_fb_var.red.offset + (240 * dst_x_offset) + (240 - dst_y_offset - h),
+ w, h, 240 );
+ /* Now U */
+ vo_pxa_copy_and_rotate( src[1] + src_x_offset/2 + (src_y_offset/2 * stride[1]), stride[1],
+ priv->fb_mem_base + priv->my_fb_var.green.offset + (120 * dst_x_offset/2) + (120 - dst_y_offset/2 - h/2),
+ w/2, h/2, 120 );
+ vo_pxa_copy_and_rotate( src[2] + src_x_offset/2 + (src_y_offset/2 * stride[2]), stride[2],
+ priv->fb_mem_base + priv->my_fb_var.blue.offset + (120 * dst_x_offset/2) + (120 - dst_y_offset/2 - h/2),
+ w/2, h/2, 120 );
+ }
+ else
+ {
+ /* Don't rotate */
+ int i;
+ uint8_t *my_src;
+ uint8_t *dest;
+ int dst_x_offset = 0;
+ int dst_y_offset = 0;
+ int src_x_offset = 0;
+ int src_y_offset = 0;
+
+ /* Figure out dst offset */
+ if( priv->src_width < 240 )
+ {
+ dst_x_offset = ( ( 240 - priv->src_width ) / 2 );
+ /* Make it a multiple of 16 */
+ dst_x_offset &= ~(0xf);
+ }
+
+ if( priv->src_height < 320 )
+ {
+ dst_y_offset = ( ( 320 - priv->src_height ) / 2 );
+ /* Make it a multiple of 16 */
+ dst_y_offset &= ~(0xf);
+ }
+
+ dst_x_offset += x;
+ dst_y_offset += y;
+
+ if( ( dst_x_offset >= 240 ) || ( dst_y_offset >= 320 ) )
+ {
+ /* Nothing to do - drawing off the screen! */
+ return( 0 );
+ }
+
+ /* Limit to drawable area */
+ if( ( w + dst_x_offset ) > 240 )
+ {
+ w = ( 240 - dst_x_offset );
+ }
+
+ if( ( h + dst_y_offset ) > 320 )
+ {
+ h = ( 320 - dst_y_offset );
+ }
+
+ /* And source offset */
+ if( priv->src_width > 240 )
+ {
+ src_x_offset = ( ( priv->src_width - 240 ) / 2 );
+ /* Make it a multiple of 16 */
+ src_x_offset &= ~(0xf);
+ }
+
+ if( priv->src_height > 320 )
+ {
+ src_y_offset = ( ( priv->src_height - 320 ) / 2 );
+ /* Make it a multiple of 16 */
+ src_y_offset &= ~(0xf);
+ }
+
+ /* First Y */
+ for( i = 0; i<h; i++ )
+ {
+ dest = priv->fb_mem_base +
+ priv->my_fb_var.red.offset +
+ ( (dst_y_offset+i) * priv->my_fb_fix.line_length ) +
+ dst_x_offset;
+ my_src = src[0] + src_x_offset + (stride[0] * (i+src_y_offset));
+ memcpy( dest, my_src, w );
+ }
+
+ /* Now U */
+ for( i = 0; i<(h/2); i++ )
+ {
+ dest = priv->fb_mem_base +
+ priv->my_fb_var.green.offset +
+ ( ((dst_y_offset/2)+i) * (priv->my_fb_fix.line_length/2) ) +
+ dst_x_offset/2;
+ my_src = src[1] + src_x_offset/2 + (stride[1] * (i+(src_y_offset/2)));
+ memcpy( dest, my_src, w/2 );
+ }
- if( w + x > priv->my_fb_fix.line_length )
- {
- w = priv->my_fb_fix.line_length - x;
+ /* Finaly V */
+ for( i = 0; i<(h/2); i++ )
+ {
+ dest = priv->fb_mem_base +
+ priv->my_fb_var.blue.offset +
+ ( ((dst_y_offset/2)+i) * (priv->my_fb_fix.line_length/2) ) +
+ dst_x_offset/2;
+ my_src = src[2] + src_x_offset/2 + (stride[2] * (i+(src_y_offset/2)));
+ memcpy( dest, my_src, w/2 );
+ }
+
+ }
}
-
- if( y>= priv->my_fb_var.yres )
+%s
>>> DIFF TRUNCATED @ 16K
More information about the Openembedded-commits
mailing list