enable/disable local alpha and global alpha -blog archive

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

enable/disable local alpha and global alpha -blog archive

5,628 Views
max_tsai
NXP Employee
NXP Employee

To enable local alpha needs 32 bpp within bootargs, like "video=mxcdi1fb:RGB666,XGA,bpp=32"

Attached a simple code to enable/disable local/global alpha bledding by ioctl below.

alpha blending

Tags (1)
11 Replies

1,680 Views
saurabh206
Senior Contributor III

Hi,

Max

Where is the attachment?


0 Kudos

1,680 Views
max_tsai
NXP Employee
NXP Employee

The attachment is broken. Attached the code below.

---

#include <stdio.h>

#include <stdlib.h>

#include <sys/types.h>

#include <sys/stat.h>

#include <fcntl.h>

#include <sys/ioctl.h>

#include <unistd.h>

//#include <asm/arch/mxcfb.h>

#define MXCFB_SET_GBL_ALPHA _IOW('F', 0x21, struct mxcfb_gbl_alpha)

#define MXCFB_SET_CLR_KEY _IOW('F', 0x22, struct mxcfb_color_key)

#define MXCFB_SET_LOC_ALPHA _IOWR('F', 0x26, struct mxcfb_loc_alpha)

struct mxcfb_gbl_alpha {

        int enable;

        int alpha;

};

struct mxcfb_color_key {

        int enable;

        __u32 color_key;

};

struct mxcfb_loc_alpha {

        int enable;

        int alpha_in_pixel;                 

        unsigned long alpha_phy_addr0;      

        unsigned long alpha_phy_addr1;      

};

int main(int argc, char **argv)

{

        int fb_fd;

        struct mxcfb_gbl_alpha gbl_alpha;

    struct mxcfb_loc_alpha l_alpha;

    struct mxcfb_color_key key;

    char fbname[128];

    char *endptr;

        if(argc < 3){

               printf("Usage: %s fb_chn [gn|ln] [alpha_val[0-255]] [color_key[0x00000000-0xffffffff]]\n",argv[0]);

               return -1;

        }

    memset(fbname, 0, sizeof(fbname));

    sprintf(fbname, "/dev/graphics/fb%s", argv[1]);

    printf("open '%s'\n", fbname);

        fb_fd = open(fbname,O_RDWR,0);

    if (fb_fd == -1) {

        perror("open");

        exit(1);

    }

    if (argv[2][0] == 'g') {

        gbl_alpha.enable = 1;

        gbl_alpha.alpha = atoi(argv[3]);

        if (ioctl(fb_fd, MXCFB_SET_GBL_ALPHA, &gbl_alpha))

            perror("ioctl");

        if (argv[2][1] == '1') {

            printf("enable global alpha blending\n");

            key.enable = 1;

        } else {

            printf("disable global alpha blending\n");

            key.enable = 0;

        }

        key.color_key = strtol(argv[4], &endptr, 16);

        printf("key = 0x%x\n", key.color_key);

        if (ioctl(fb_fd, MXCFB_SET_CLR_KEY, &key))

            perror("ioctl");

    } else if (argv[2][0] =='l') {

        if (argv[2][1] == '1') {

            l_alpha.enable = 1;

            printf("enable local alpha blending\n");

        } else {

            l_alpha.enable = 0;

            printf("disable local alpha blending\n");

        }

        l_alpha.alpha_in_pixel = 1;

        if (ioctl(fb_fd, MXCFB_SET_LOC_ALPHA, &l_alpha))

            perror("ioctl");

    }

        close(fb_fd);

        return 0;

}

0 Kudos

1,680 Views
saurabh206
Senior Contributor III

Hi,

Max

Thanks for sharing the code.

Our setup  is like data from android surface flinger is available "/dev/graphics/fb0"

We want to do overlay with CSI buffer which is written on "/dev/graphics/fb1"

We are able to get it working with global alpha and colour keying. But due to some limitation with our GUI we can not use global alpha.

But If I disable global alpha and enable the local alpha than data from /dev/graphics/fb1 is not display.

- Is it possible to do alpha blending using local alpha without colour keying?

- What is a significance of alpha_phy_addr0, alpha_phy_addr1 and alpha_in_pixel?

Thanks

Saurabh

0 Kudos

1,680 Views
max_tsai
NXP Employee
NXP Employee

hi Your data going to show into framebuffer must include alpha information(ARGB), so the pixel size of framebuffer should be 32bpp.

alpha_in_pixel means each pixel embedds alpha channel, and alpha_phy_addr are the buffers used by IPU.

0 Kudos

1,680 Views
max_tsai
NXP Employee
NXP Employee

BTW, color key should work with global alpha. IPU get alpha info from each pixel for local alpha, and color key doesn't mater for local alpha. you can refer to "hardware/mx5x/libgralloc/framebuffer.cpp".

0 Kudos

1,680 Views
saurabh206
Senior Contributor III

Hi,

Max

Thanks for the valuable information.

Our fame buffer is 32bit and it should contain ARGB format. I will verify this.

"hardware/imx/mx5x/libgralloc/framebuffer.cpp" will be used for imx6q.

To enable local alpha I need to build source code without "HAVE_FSL_EPDC_FB".

Can you please explain that what is significance of HAVE_FSL_EPDC_FB?

- Saurabh

0 Kudos

1,680 Views
max_tsai
NXP Employee
NXP Employee

hi I trace FSL ICS and FSL JB, "HAVE_FSL_EPDC_FB" "hardware/imx/mx6/libgralloc_wrapper/Android.mk" is marked.

Also alpha blending configuration should not be related with this flag.

0 Kudos

1,680 Views
saurabh206
Senior Contributor III

Hi,

I have modified the frame buffer code to pass alpha channel.

hardware\imx\mx6\libgralloc_wrapper\framebuffer.cpp

        info.bits_per_pixel = 32;

        info.red.offset     = 8;     

        info.red.length     = 8;

        info.green.offset   = 16;

        info.green.length   = 8;

        info.blue.offset    = 24;

        info.blue.length    = 8;

        info.transp.offset  = 0;

        info.transp.length  = 8;  //We need local alpha transparency

And I am enabling the local alpha channel by following code.

int set_local_alpha()
{
   struct mxcfb_loc_alpha loc_alpha;
   int fd_fb;

   if ((fd_fb = open("/dev/graphics/fb0", O_RDWR, 0)) < 0)
   {
       __android_log_print(ANDROID_LOG_DEBUG,CF_TAG,"unable to open /dev/graphics/fb0 ");
       return 0;
   }

loc_alpha.alpha_in_pixel = 0;
loc_alpha.enable = 1;
   loc_alpha.alpha_phy_addr0=0;
   loc_alpha.alpha_phy_addr1=0;

if ( ioctl(fd_fb, MXCFB_SET_LOC_ALPHA, &loc_alpha) < 0) {
       __android_log_print(ANDROID_LOG_DEBUG,CF_TAG,"Error in applying Local Alpha\n");
}
   close (fd_fb);
  
}

After setting the local alpha I got only blue screen on display, no Android UI or not CSI content.

Do you have idea, what part is missing?

0 Kudos

1,680 Views
max_tsai
NXP Employee
NXP Employee

loc_alpha.alpha_in_pixel should be 1 to indicate there is alpha information per each pixel.

0 Kudos

1,680 Views
saurabh206
Senior Contributor III

HI,

Max

I got it working.

Thanks for your support.

loc_alpha.alpha_in_pixel = 1;

loc_alpha.enable = 1;

   loc_alpha.alpha_phy_addr0=0;

   loc_alpha.alpha_phy_addr1=0;

if ( ioctl(fd_fb, MXCFB_SET_LOC_ALPHA, &loc_alpha) < 0) {
       __android_log_print(ANDROID_LOG_DEBUG,CF_TAG,"Error in applying Local Alpha\n");
}

Is required to get local alpha working.

Thanks

Saurabh

0 Kudos

1,680 Views
LeonardoSandova
Specialist I

Actually seems that is not an attachment, it is a link but the link is broken MaxTsai.

0 Kudos