예제 #1
0
/* 888RLE image format: [count(2 bytes), rle(3 bytes)] */
int load_565rle_image(char *filename)
{
	struct fb_info *info;
	int fd, count, err = 0;
	unsigned max;
	unsigned char *data, *ptr;
	unsigned int *bits;
	unsigned int pixel;


	info = registered_fb[0];
	if (!info) {
		printk(KERN_WARNING "%s: Can not access framebuffer\n",
			__func__);
		return -ENODEV;
	}

	fd = sys_open(filename, O_RDONLY, 0);
	if (fd < 0) {
		printk(KERN_WARNING "%s: Can not open %s\n",
			__func__, filename);
		return -ENOENT;
	}
	count = sys_lseek(fd, (off_t)0, 2);
	if (count <= 0) {
		err = -EIO;
		goto err_logo_close_file;
	}
	sys_lseek(fd, (off_t)0, 0);
	data = kmalloc(count, GFP_KERNEL);
	if (!data) {
		printk(KERN_WARNING "%s: Can not alloc data\n", __func__);
		err = -ENOMEM;
		goto err_logo_close_file;
	}
	if (sys_read(fd, (char *)data, count) != count) {
		err = -EIO;
		goto err_logo_free_data;
	}

	max = fb_width(info) * fb_height(info);
	ptr = data;
	bits = (unsigned int *)(info->screen_base);
	while (count > 4) {
		unsigned n = ptr[0] | ptr[1] << 8;
		if (n > max)
			break;

		pixel = (0xff<<24)|(ptr[4]<<16)|(ptr[3]<<8)|ptr[2];

		memset32(bits, pixel, n << 1);
		bits += n;
		max -= n;
		ptr += 5;
		count -= 5;
	}

err_logo_free_data:
	kfree(data);
err_logo_close_file:
	sys_close(fd);
	return err;
}
예제 #2
0
/* 565RLE image format: [count(2 bytes), rle(2 bytes)] */
int load_565rle_image(char *filename)
{
	struct fb_info *info;
	int fd, err = 0;
	unsigned count, max;
	unsigned short *data, *bits, *ptr;

	printk(KERN_WARNING "~~  %s:  %s\n",__func__, filename);
	info = registered_fb[0];
	if (!info) {
		printk(KERN_WARNING "%s: Can not access framebuffer\n",
			__func__);
		return -ENODEV;
	}

	fd = sys_open(filename, O_RDONLY, 0);
	if (fd < 0) {
		printk(KERN_WARNING "%s: Can not open %s\n",
			__func__, filename);
		return -ENOENT;
	}
	count = (unsigned)sys_lseek(fd, (off_t)0, 2);
	if (count == 0) {
		sys_close(fd);
		err = -EIO;
		goto err_logo_close_file;
	}
	sys_lseek(fd, (off_t)0, 0);
	data = kmalloc(count, GFP_KERNEL);
	if (!data) {
		printk(KERN_WARNING "%s: Can not alloc data\n", __func__);
		err = -ENOMEM;
		goto err_logo_close_file;
	}
	if ((unsigned)sys_read(fd, (char *)data, count) != count) {
		err = -EIO;
		goto err_logo_free_data;
	}

	max = fb_width(info) * fb_height(info);
	ptr = data;
	bits = (unsigned short *)(info->screen_base);
	while (count > 3) {
		unsigned n = ptr[0];
		if (n > max)
			break;
		memset16(bits, ptr[1], n << 1);
		bits += n;
		max -= n;
		ptr += 2;
		count -= 4;
	}

err_logo_free_data:
	kfree(data);

err_logo_close_file:
	sys_close(fd);

	printk(KERN_WARNING "~~  %s:  %s  err:%d end \n",__func__, filename, err);

	return err;
}
예제 #3
0
/* 565RLE image format: [count(2 bytes), rle(2 bytes)] */
static int load_565rle_image(char *filename)
{
	struct fb_info *info;
	int fd, err = 0;
	unsigned max, width, stride, line_pos = 0;
	unsigned short *data, *ptr;
	unsigned char *bits;
	signed count;

	info = registered_fb[0];
	if (!info) {
		printk(KERN_ERR "%s: Can not access framebuffer\n",
			__func__);
		return -ENODEV;
	}

	fd = sys_open(filename, O_RDONLY, 0);
	if (fd < 0) {
		printk(KERN_ERR "%s: Can not open %s\n",
			__func__, filename);
		return -ENOENT;
	}
	count = sys_lseek(fd, (off_t)0, 2);
	if (count <= 0) {
		err = -EIO;
		printk(KERN_ERR "%s: sys_lseek failed %s\n",
			__func__, filename);
		goto err_logo_close_file;
	}
	sys_lseek(fd, (off_t)0, 0);
	data = kmalloc(count, GFP_KERNEL);
	if (!data) {
		printk(KERN_ERR "%s: Can not alloc data\n", __func__);
		err = -ENOMEM;
		goto err_logo_close_file;
	}
	if (sys_read(fd, (char *)data, count) != count) {
		err = -EIO;
		printk(KERN_ERR "%s: sys_read failed %s\n",
			__func__, filename);
		goto err_logo_free_data;
	}
	width = fb_width(info);
	stride = fb_linewidth(info);
	max = width * fb_height(info);
	ptr = data;
	bits = (unsigned char *)(info->screen_base);
	while (count > 3) {
		int n = ptr[0];

		if (n > max)
			break;
		max -= n;
		while (n > 0) {
			unsigned int j =
				(line_pos+n > width ? width-line_pos : n);

			if (fb_depth(info) == 2) {
				memset16(bits, ptr[1], j << 1);
			} else {
				/* Should probably add check for framebuffer
				 * format here*/
				unsigned int widepixel = ptr[1];
				widepixel = (widepixel & 0xf800) << (19-11) |
					(widepixel & 0x07e0) << (10-5) |
					(widepixel & 0x001f) << (3-0) |
					0xff000000; /* Set alpha channel*/
				memset32(bits, widepixel, j << 2);
			}
			bits += j * fb_depth(info);
			line_pos += j;
			n -= j;
			if (line_pos == width) {
				bits += (stride-width) * fb_depth(info);
				line_pos = 0;
			}
		}
		ptr += 2;
		count -= 4;
	}

err_logo_free_data:
	kfree(data);
err_logo_close_file:
	sys_close(fd);

	return err;
}
예제 #4
0
int load_565rle_image(char *filename, bool bf_supported)
{
    int fd, err = 0;
    unsigned count, max;
    unsigned short *data, *bits, *ptr;
    struct fb_info *info;
#if 0
    struct module *owner;
#endif
    info = registered_fb[0];

    if (!info) {
        printk(KERN_WARNING "%s: Can not access framebuffer\n",
               __func__);
        return -ENODEV;
    }
#if 0
    owner = info->fbops->owner;
    if (!try_module_get(owner))
        return NULL;
    if (info->fbops->fb_open && info->fbops->fb_open(info, 0)) {
        module_put(owner);
        return NULL;
    }
#endif
    fd = sys_open(filename, O_RDONLY, 0);
    if (fd < 0) {
        printk(KERN_WARNING "%s: Can not open %s\n",
               __func__, filename);
        return -ENOENT;
    }
    printk("%s: open OK! %s\n",__func__, filename);
    count = (unsigned)sys_lseek(fd, (off_t)0, 2);
    if (count == 0) {
        sys_close(fd);
        err = -EIO;
        goto err_logo_close_file;
    }
    printk("%s: count %d\n",__func__, count);
    sys_lseek(fd, (off_t)0, 0);
    data = kmalloc(count, GFP_KERNEL);
    if (!data) {
        printk(KERN_WARNING "%s: Can not alloc data\n", __func__);
        err = -ENOMEM;
        goto err_logo_close_file;
    }
    if ((unsigned)sys_read(fd, (char *)data, count) != count) {
        err = -EIO;
        goto err_logo_free_data;
    }

    max = fb_width(info) * fb_height(info);

    ptr = data;
    bits = (unsigned short *)(info->screen_base);
    printk("%s: max %d, n %d 0x%x\n",__func__, max, ptr[0], (unsigned int)bits);
    while (count > 3) {
        unsigned n = ptr[0];
        if (n > max)
            break;

        memset16_rgb8888(bits, ptr[1], n << 1);
        bits += n*2; // for rgb8888
        max -= n;
        ptr += 2;
        count -= 4;
    }
#if !defined (CONFIG_USA_OPERATOR_ATT) && !defined (CONFIG_JPN_MODEL_SC_03D) && !defined (CONFIG_CAN_OPERATOR_RWC)
    if (!is_lpcharging_state() && !sec_debug_is_recovery_mode())
        s3cfb_start_progress(info);
#endif

err_logo_free_data:
    kfree(data);
err_logo_close_file:
    sys_close(fd);
    return err;
}
예제 #5
0
/* 565RLE image format: [count(2 bytes), rle(2 bytes)] */
int load_565rle_image(char *filename, bool bf_supported)
{
	struct fb_info *info;
	int fd, count, err = 0;
	unsigned max;
	unsigned short *data, *bits, *ptr;
#ifndef CONFIG_FRAMEBUFFER_CONSOLE
	struct module *owner;
#endif
	int pad;

	info = registered_fb[0];
	if (!info) {
		printk(KERN_WARNING "%s: Can not access framebuffer\n",
			__func__);
		return -ENODEV;
	}
#ifndef CONFIG_FRAMEBUFFER_CONSOLE
	owner = info->fbops->owner;
	if (!try_module_get(owner))
		return -ENODEV;
	if (info->fbops->fb_open && info->fbops->fb_open(info, 0)) {
		module_put(owner);
		return -ENODEV;
	}
#endif

	fd = sys_open(filename, O_RDONLY, 0);
	if (fd < 0) {
		printk(KERN_WARNING "%s: Can not open %s\n",
			__func__, filename);
		return -ENOENT;
	}
	count = sys_lseek(fd, (off_t)0, 2);
	if (count <= 0) {
		err = -EIO;
		goto err_logo_close_file;
	}
	sys_lseek(fd, (off_t)0, 0);
	data = kmalloc(count, GFP_KERNEL);
	if (!data) {
		printk(KERN_WARNING "%s: Can not alloc data\n", __func__);
		err = -ENOMEM;
		goto err_logo_close_file;
	}
	if (sys_read(fd, (char *)data, count) != count) {
		err = -EIO;
		goto err_logo_free_data;
	}

	max = fb_width(info) * fb_height(info);
	ptr = data;
	if (bf_supported && (info->node == 1 || info->node == 2)) {
		err = -EPERM;
		pr_err("%s:%d no info->creen_base on fb%d!\n",
		       __func__, __LINE__, info->node);
		goto err_logo_free_data;
	}
	if (info->screen_base) {
		bits = (unsigned short *)(info->screen_base);
		while (count > 3) {
			unsigned n = ptr[0];
			if (n > max)
				break;
			if (info->var.bits_per_pixel >= 24) {
				pad = memset16_rgb8888(bits, ptr[1], n << 1, info);
				bits += n << 1;
				bits += pad;
			} else {
			memset16(bits, ptr[1], n << 1);
			bits += n;
			}
			max -= n;
			ptr += 2;
			count -= 4;
		}
	}
	err = 0;
err_logo_free_data:
	kfree(data);
err_logo_close_file:
	sys_close(fd);
	return err;
}
/* 565RLE image format: [count(2 bytes), rle(2 bytes)] */
int load_565rle_image(char *filename)
{
	struct fb_info *info;
	int fd, err = 0;
	unsigned count, max, width, stride, line_pos = 0;
	unsigned short *data, *ptr;
	unsigned char *bits;

	info = registered_fb[0];
	if (!info) {
		printk(KERN_WARNING "%s: Can not access framebuffer\n",
			__func__);
		return -ENODEV;
	}

	if (!info->screen_base) {
		printk(KERN_WARNING "Framebuffer memory not allocated\n");
		return -ENOMEM;
	}

	fd = sys_open(filename, O_RDONLY, 0);
	if (fd < 0) {
		printk(KERN_WARNING "%s: Can not open %s\n",
			__func__, filename);
		return -ENOENT;
	}
	count = sys_lseek(fd, (off_t)0, 2);
	if (count <= 0) {
		err = -EIO;
		goto err_logo_close_file;
	}
	sys_lseek(fd, (off_t)0, 0);
	data = kmalloc(count, GFP_KERNEL);
	if (!data) {
		printk(KERN_WARNING "%s: Can not alloc data\n", __func__);
		err = -ENOMEM;
		goto err_logo_close_file;
	}
	if (sys_read(fd, (char *)data, count) != count) {
		err = -EIO;
		goto err_logo_free_data;
	}
	width = fb_width(info);
	stride = fb_linewidth(info);
	max = width * fb_height(info);
	ptr = data;
	bits = (unsigned char *)(info->screen_base);

	while (count > 3) {
		int n = ptr[0];

		if (n > max)
			break;
		max -= n;
		while (n > 0) {
			unsigned int j =
				(line_pos + n > width ? width-line_pos : n);

			if (fb_depth(info) == 2)
				memset16(bits, ptr[1], j << 1);
			else {
				unsigned int widepixel = ptr[1];
				/*
				 * Format is RGBA, but fb is big
				 * endian so we should make widepixel
				 * as ABGR.
				 */
				widepixel =
					/* red :   f800 -> 000000f8 */
					(widepixel & 0xf800) >> 8 |
					/* green : 07e0 -> 0000fc00 */
					(widepixel & 0x07e0) << 5 |
					/* blue :  001f -> 00f80000 */
					(widepixel & 0x001f) << 19;
				memset32(bits, widepixel, j << 2);
			}
			bits += j * fb_depth(info);
			line_pos += j;
			n -= j;
			if (line_pos == width) {
				bits += (stride-width) * fb_depth(info);
				line_pos = 0;
			}
		}
		ptr += 2;
		count -= 4;
	}

err_logo_free_data:
	kfree(data);
err_logo_close_file:
	sys_close(fd);

	return err;
}
예제 #7
0
/*MTD-MM-CL-DrawLogo-00+[*/
int fih_load_565rle_image(char *filename)
{
	struct fb_info *info  = NULL;
	struct file    *filp  = NULL;
	unsigned short *ptr  = NULL;
	unsigned char  *bits = NULL;
	unsigned char  *data = NULL;
	unsigned max = 0;
	int bits_count = 0, count = 0, err = 0;

	mm_segment_t old_fs = get_fs();
	set_fs (get_ds());
	printk(KERN_INFO "[DISPLAY] %s\n", __func__);

	info = registered_fb[0];
	if (!info) {
		printk(KERN_WARNING "%s: Can not access framebuffer\n",
			__func__);
		return -ENODEV;
	}

	filp = filp_open(filename, O_RDONLY, 0);
	if (IS_ERR(filp)) {
		printk(KERN_ERR "%s: Can not open %s\n",
			__func__, filename);
		err = -ENOENT;
		goto error2;
	}

	count = filp->f_dentry->d_inode->i_size;
	data = kmalloc(count, GFP_KERNEL);
	if (!data) {
		printk(KERN_ERR "%s: Can not alloc data\n", __func__);
		err = -ENOMEM;;
		goto error1;
	}

	if (filp->f_op->read(filp, data, count, &filp->f_pos) < 0) {
		printk(KERN_ERR "%s: read file error?\n", __func__);
		err = -EIO;
		goto error1;
	}

	max = fb_width(info) * fb_height(info);
	ptr = (unsigned short *)data;
	bits = (unsigned char *)(info->screen_base);

	while (count > 3) {
		unsigned n = ptr[0];
		if (n > max)
			break;
		bits_count = n;
		#if defined(CONFIG_FB_MSM_DEFAULT_DEPTH_RGBA8888)
		while (bits_count--) {
			*bits++ = (ptr[1] & 0xF800) >> 8;
			*bits++ = (ptr[1] & 0x7E0) >> 3;
			*bits++ = (ptr[1] & 0x1F) << 3;
			*bits++ = 0xFF;
		}
		#else
		memset16(bits, ptr[1], n << 1);
		bits += n;
		#endif
		max -= n;
		ptr += 2;
		count -= 4;
	}

error1:
	filp_close(filp, NULL);
	kfree(data);
error2:
	set_fs(old_fs);
	return err;
}
예제 #8
0
/* 565RLE image format: [count(2 bytes), rle(2 bytes)] */
int load_565rle_image(char *filename)
{
	struct fb_info *info;
	int fd, count, err = 0;
	unsigned max;
	unsigned short *data, *ptr;
#ifdef CONFIG_LGE_I_DISP_BOOTLOGO
	char *bits;
#else
	unsigned int *bits;
#endif

	info = registered_fb[0];
	if (!info) {
		printk(KERN_WARNING "%s: Can not access framebuffer\n",
			__func__);
		return -ENODEV;
	}

	fd = sys_open(filename, O_RDONLY, 0);
	if (fd < 0) {
		printk(KERN_WARNING "%s: Can not open %s\n",
			__func__, filename);
		return -ENOENT;
	}
	count = sys_lseek(fd, (off_t)0, 2);
	if (count <= 0) {
		err = -EIO;
		goto err_logo_close_file;
	}
	sys_lseek(fd, (off_t)0, 0);
	data = kmalloc(count, GFP_KERNEL);
	if (!data) {
		printk(KERN_WARNING "%s: Can not alloc data\n", __func__);
		err = -ENOMEM;
		goto err_logo_close_file;
	}
	if (sys_read(fd, (char *)data, count) != count) {
		err = -EIO;
		goto err_logo_free_data;
	}

	max = fb_width(info) * fb_height(info);
	ptr = data;
#ifdef CONFIG_LGE_I_DISP_BOOTLOGO
	bits = (char *)(info->screen_base);
#else
	bits = (unsigned short *)(info->screen_base);
#endif

	while (count > 3) {
		unsigned n = ptr[0];
		if (n > max)
			break;
#ifdef CONFIG_LGE_I_DISP_BOOTLOGO
		if(info->var.bits_per_pixel/8 == 4){
			memset32(bits, ptr[1], n << 1);
		}
		else{
			memset16(bits, ptr[1], n << 1);
		}
		bits += info->var.bits_per_pixel/8*n;
#else
		memset16(bits, ptr[1], n << 1);
		bits += n;
#endif

		max -= n;
		ptr += 2;
		count -= 4;
	}

err_logo_free_data:
	kfree(data);
err_logo_close_file:
	sys_close(fd);
	return err;
}
예제 #9
0
파일: daemon.c 프로젝트: CurlyMoo/Splash
void main_draw_black(void) {
	if(nodaemon == 0) {
		draw_rectangle_filled(0, 0, -1, fb_width(), fb_height(), draw_color(0, 0, 0));
	}
}
예제 #10
0
static sqInt display_ioScreenSize(void)
{
  return ((fb_width(fb) << 16) | fb_height(fb));
}
예제 #11
0
/* 565RLE image format: [count(2 bytes), rle(2 bytes)] */
int load_565rle_image(char *filename)
{
	struct fb_info *info;
	int fd, count, err = 0;
	unsigned max;
	unsigned short *data, *ptr;
    char *bits;
    pixel_set_t pixel_set;

	info = registered_fb[0];
	if (!info) {
		printk(KERN_WARNING "%s: Can not access framebuffer\n",
			__func__);
		return -ENODEV;
	}
    
    switch (info->var.bits_per_pixel) {
    case 16:
        pixel_set = memset16;
        break;
    case 32:
        pixel_set = pixel_set_rgba;
        break;
    default:
		printk(KERN_WARNING "%s: Can not find pixel_set operation\n",
			__func__);    
		return -EDOM;
    }

	fd = sys_open(filename, O_RDONLY, 0);
	if (fd < 0) {
		printk(KERN_WARNING "%s: Can not open %s\n",
			__func__, filename);
		return -ENOENT;
	}
	count = sys_lseek(fd, (off_t)0, 2);
	if (count <= 0) {
		err = -EIO;
		goto err_logo_close_file;
	}
	sys_lseek(fd, (off_t)0, 0);
	data = kmalloc(count, GFP_KERNEL);
	if (!data) {
		printk(KERN_WARNING "%s: Can not alloc data\n", __func__);
		err = -ENOMEM;
		goto err_logo_close_file;
	}
	if (sys_read(fd, (char *)data, count) != count) {
		err = -EIO;
		goto err_logo_free_data;
	}

	max = fb_width(info) * fb_height(info);
	ptr = data;
	bits = info->screen_base;
	while (count > 3) {
		unsigned n = ptr[0];
		if (n > max)
			break;
		bits += pixel_set(bits, ptr[1], n);
		max -= n;
		ptr += 2;
		count -= 4;
	}

err_logo_free_data:
	kfree(data);
err_logo_close_file:
	sys_close(fd);
	return err;
}
예제 #12
0
/* 565RLE image format: [count(2 bytes), rle(2 bytes)] */
int load_565rle_image(char *filename)
{
	struct fb_info *info;
	int fd, err = 0;
	unsigned count, max;
	char *data, *bits, *ptr;
	printk("LUYA!!!!1 load_565rle_image\n");

	info = registered_fb[0];
	if (!info) {
		printk(KERN_WARNING "%s: Can not access framebuffer\n",
			__func__);
		return -ENODEV;
	}
	printk("LUYA!!!!2 load_565rle_image\n");

	fd = sys_open(filename, O_RDONLY, 0);
	if (fd < 0) {
		printk(KERN_WARNING "%s: Can not open %s\n",
			__func__, filename);
		return -ENOENT;
	}
	max = fb_width(info) * fb_height(info)*4;
	printk("LUYA!!!!max=%d\n",max);


	count = (unsigned)sys_lseek(fd, (off_t)0, 2);
	printk("LUYA!!!!count=%d\n",count);
	
	if (count == 0) {
		sys_close(fd);
		err = -EIO;
		goto err_logo_close_file;
	}

	sys_lseek(fd, (off_t)0, 0);

	data = kmalloc(count, GFP_KERNEL);
	if (!data) {
		printk(KERN_WARNING "%s: Can not alloc data\n", __func__);
		err = -ENOMEM;
		goto err_logo_close_file;
	}
	if ((unsigned)sys_read(fd, (char *)data, count) != count) {
		err = -EIO;
		goto err_logo_free_data;
	}  
	ptr = data+54;
	bits = (char *)(info->screen_base);

	//memcpy((void *)info->screen_base,(void *)(data+27),480*800*4);

	while (max > 0) {
//		unsigned n = ptr[0];
//		if (n > max)
//			break;
		//memset16(bits, ptr[0], 1 << 1);
		//memset16(bits+1, ptr[3], 1 << 1);
		//memset16(bits+2, ptr[2], 1 << 1);
		//memset16(bits+3, ptr[1], 1 << 1);
		bits[0] = ptr[2];
		bits[1] = ptr[1];
		bits[2] = ptr[0];
		bits[3] = ptr[3];
		bits += 4;
		max -= 4;  
		ptr += 4;
		
//		count -= 1;
	}
err_logo_free_data:
	kfree(data);
err_logo_close_file:
	sys_close(fd);
	return err;
}
/* 565RLE image format: [count(2 bytes), rle(2 bytes)] */
int load_565rle_image(char *filename, bool bf_supported)
{
	struct fb_info *info;
	int fd, count, err = 0;
	unsigned max;
	unsigned short *data, *ptr ;
	uint32_t *bits;
	unsigned int out;

	info = registered_fb[0];
	if (!info) {
		printk(KERN_WARNING "%s: Can not access framebuffer\n",
			__func__);
		return -ENODEV;
	}

	fd = sys_open(filename, O_RDONLY, 0);
	if (fd < 0) {
		printk(KERN_WARNING "%s: Can not open %s\n",
			__func__, filename);
		return -ENOENT;
	}
	count = sys_lseek(fd, (off_t)0, 2);
	if (count <= 0) {
		err = -EIO;
		goto err_logo_close_file;
	}
	sys_lseek(fd, (off_t)0, 0);
	data = kmalloc(count, GFP_KERNEL);
	if (!data) {
		printk(KERN_WARNING "%s: Can not alloc data\n", __func__);
		err = -ENOMEM;
		goto err_logo_close_file;
	}
	if (sys_read(fd, (char *)data, count) != count) {
		err = -EIO;
		goto err_logo_free_data;
	}

	max = fb_width(info) * fb_height(info);
	ptr = data;
	if (bf_supported && (info->node == 1 || info->node == 2)) {
		err = -EPERM;
		pr_err("%s:%d no info->creen_base on fb%d!\n",
		       __func__, __LINE__, info->node);
		goto err_logo_free_data;
	}
	bits = (uint32_t*)(info->screen_base);
	while (count > 3) {
		unsigned n = ptr[0];
		if (n > max)
			break;
		out = rgb32(ptr[1]);  

		memset32(bits, out, n << 2);
		bits += n;
		max -= n;
		ptr += 2;
		count -= 4;
	}

err_logo_free_data:
	kfree(data);
err_logo_close_file:
	sys_close(fd);
	return err;
}
예제 #14
0
파일: logo.c 프로젝트: AnDr0id/SGH-I747
/* 565RLE image format: [count(2 bytes), rle(2 bytes)] */
int load_565rle_image(char *filename)
{
	struct fb_info *info;
	int fd, count, err = 0;
	unsigned max;
	unsigned short *data, *bits, *ptr;
#ifndef CONFIG_FRAMEBUFFER_CONSOLE
	struct module *owner;
#endif
	int pad;

	info = registered_fb[0];
	if (!info) {
		printk(KERN_WARNING "%s: Can not access framebuffer\n",
			__func__);
		return -ENODEV;
	}

#ifndef CONFIG_FRAMEBUFFER_CONSOLE
	owner = info->fbops->owner;
	if (!try_module_get(owner))
		return -ENODEV;
	if (info->fbops->fb_open && info->fbops->fb_open(info, 0)) {
		module_put(owner);
		return -ENODEV;
	}
#endif

	fd = sys_open(filename, O_RDONLY, 0);
	if (fd < 0) {
		printk(KERN_WARNING "%s: Can not open %s\n",
			__func__, filename);
		return -ENOENT;
	}
	count = sys_lseek(fd, (off_t)0, 2);
	if (count <= 0) {
		err = -EIO;
		goto err_logo_close_file;
	}
	sys_lseek(fd, (off_t)0, 0);
	data = kmalloc(count, GFP_KERNEL);
	if (!data) {
		printk(KERN_WARNING "%s: Can not alloc data\n", __func__);
		err = -ENOMEM;
		goto err_logo_close_file;
	}
	if (sys_read(fd, (char *)data, count) != count) {
		err = -EIO;
		goto err_logo_free_data;
	}

	max = fb_width(info) * fb_height(info);
	ptr = data;
	bits = (unsigned short *)(info->screen_base);
	while (count > 3) {
		unsigned n = ptr[0];
		if (n > max)
			break;
		if (info->var.bits_per_pixel >= 24) {
			pad = memset16_rgb8888(bits, ptr[1], n << 1, info);
			bits += n << 1;
			bits += pad;
		} else {
			memset16(bits, ptr[1], n << 1);
			bits += n;
		}
		max -= n;
		ptr += 2;
		count -= 4;
	}

#if defined(CONFIG_FB_MSM_MIPI_SAMSUNG_OLED_CMD_QHD_PT) \
	|| defined(CONFIG_FB_MSM_MIPI_NOVATEK_BOE_CMD_WVGA_PT)
	flush_cache_all();
	outer_flush_all();
#endif

err_logo_free_data:
	kfree(data);
err_logo_close_file:
	sys_close(fd);

#ifndef CONFIG_FRAMEBUFFER_CONSOLE
	err = fb_pan_display(info, &info->var);
	if (err < 0) {
		printk(KERN_WARNING "%s: Can not update framebuffer\n",
			__func__);
		return -ENODEV;
	}
#endif

	return err;
}