2020-02-16 02:09:11 +08:00
|
|
|
// SPDX-License-Identifier: GPL-2.0 or MIT
|
2019-04-05 17:52:15 +08:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2016 Noralf Trønnes
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*/
|
|
|
|
|
2022-08-08 20:53:54 +08:00
|
|
|
#include <linux/io.h>
|
|
|
|
#include <linux/iosys-map.h>
|
2019-04-05 17:52:15 +08:00
|
|
|
#include <linux/module.h>
|
|
|
|
#include <linux/slab.h>
|
|
|
|
|
2022-02-14 21:37:06 +08:00
|
|
|
#include <drm/drm_device.h>
|
2019-04-05 17:52:15 +08:00
|
|
|
#include <drm/drm_format_helper.h>
|
|
|
|
#include <drm/drm_framebuffer.h>
|
|
|
|
#include <drm/drm_fourcc.h>
|
2022-02-14 21:37:06 +08:00
|
|
|
#include <drm/drm_print.h>
|
2019-04-05 17:52:15 +08:00
|
|
|
#include <drm/drm_rect.h>
|
|
|
|
|
2021-11-10 18:36:54 +08:00
|
|
|
static unsigned int clip_offset(const struct drm_rect *clip, unsigned int pitch, unsigned int cpp)
|
2019-04-05 17:52:16 +08:00
|
|
|
{
|
2019-04-10 14:38:13 +08:00
|
|
|
return clip->y1 * pitch + clip->x1 * cpp;
|
2019-04-05 17:52:16 +08:00
|
|
|
}
|
|
|
|
|
2021-11-10 18:36:54 +08:00
|
|
|
/**
|
|
|
|
* drm_fb_clip_offset - Returns the clipping rectangles byte-offset in a framebuffer
|
|
|
|
* @pitch: Framebuffer line pitch in byte
|
|
|
|
* @format: Framebuffer format
|
|
|
|
* @clip: Clip rectangle
|
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
* The byte offset of the clip rectangle's top-left corner within the framebuffer.
|
|
|
|
*/
|
|
|
|
unsigned int drm_fb_clip_offset(unsigned int pitch, const struct drm_format_info *format,
|
|
|
|
const struct drm_rect *clip)
|
|
|
|
{
|
|
|
|
return clip_offset(clip, pitch, format->cpp[0]);
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL(drm_fb_clip_offset);
|
|
|
|
|
2022-08-08 20:54:05 +08:00
|
|
|
/* TODO: Make this function work with multi-plane formats. */
|
|
|
|
static int __drm_fb_xfrm(void *dst, unsigned long dst_pitch, unsigned long dst_pixsize,
|
|
|
|
const void *vaddr, const struct drm_framebuffer *fb,
|
|
|
|
const struct drm_rect *clip, bool vaddr_cached_hint,
|
|
|
|
void (*xfrm_line)(void *dbuf, const void *sbuf, unsigned int npixels))
|
2022-04-27 22:14:09 +08:00
|
|
|
{
|
|
|
|
unsigned long linepixels = drm_rect_width(clip);
|
|
|
|
unsigned long lines = drm_rect_height(clip);
|
|
|
|
size_t sbuf_len = linepixels * fb->format->cpp[0];
|
|
|
|
void *stmp = NULL;
|
|
|
|
unsigned long i;
|
|
|
|
const void *sbuf;
|
|
|
|
|
|
|
|
/*
|
2022-08-02 08:04:02 +08:00
|
|
|
* Some source buffers, such as DMA memory, use write-combine
|
2022-04-27 22:14:09 +08:00
|
|
|
* caching, so reads are uncached. Speed up access by fetching
|
|
|
|
* one line at a time.
|
|
|
|
*/
|
|
|
|
if (!vaddr_cached_hint) {
|
|
|
|
stmp = kmalloc(sbuf_len, GFP_KERNEL);
|
|
|
|
if (!stmp)
|
|
|
|
return -ENOMEM;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!dst_pitch)
|
|
|
|
dst_pitch = drm_rect_width(clip) * dst_pixsize;
|
|
|
|
vaddr += clip_offset(clip, fb->pitches[0], fb->format->cpp[0]);
|
|
|
|
|
|
|
|
for (i = 0; i < lines; ++i) {
|
|
|
|
if (stmp)
|
|
|
|
sbuf = memcpy(stmp, vaddr, sbuf_len);
|
|
|
|
else
|
|
|
|
sbuf = vaddr;
|
|
|
|
xfrm_line(dst, sbuf, linepixels);
|
|
|
|
vaddr += fb->pitches[0];
|
|
|
|
dst += dst_pitch;
|
|
|
|
}
|
|
|
|
|
|
|
|
kfree(stmp);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2022-08-08 20:54:05 +08:00
|
|
|
/* TODO: Make this function work with multi-plane formats. */
|
|
|
|
static int __drm_fb_xfrm_toio(void __iomem *dst, unsigned long dst_pitch, unsigned long dst_pixsize,
|
|
|
|
const void *vaddr, const struct drm_framebuffer *fb,
|
|
|
|
const struct drm_rect *clip, bool vaddr_cached_hint,
|
|
|
|
void (*xfrm_line)(void *dbuf, const void *sbuf, unsigned int npixels))
|
2022-04-27 22:14:09 +08:00
|
|
|
{
|
|
|
|
unsigned long linepixels = drm_rect_width(clip);
|
|
|
|
unsigned long lines = drm_rect_height(clip);
|
|
|
|
size_t dbuf_len = linepixels * dst_pixsize;
|
|
|
|
size_t stmp_off = round_up(dbuf_len, ARCH_KMALLOC_MINALIGN); /* for sbuf alignment */
|
|
|
|
size_t sbuf_len = linepixels * fb->format->cpp[0];
|
|
|
|
void *stmp = NULL;
|
|
|
|
unsigned long i;
|
|
|
|
const void *sbuf;
|
|
|
|
void *dbuf;
|
|
|
|
|
|
|
|
if (vaddr_cached_hint) {
|
|
|
|
dbuf = kmalloc(dbuf_len, GFP_KERNEL);
|
|
|
|
} else {
|
|
|
|
dbuf = kmalloc(stmp_off + sbuf_len, GFP_KERNEL);
|
|
|
|
stmp = dbuf + stmp_off;
|
|
|
|
}
|
|
|
|
if (!dbuf)
|
|
|
|
return -ENOMEM;
|
|
|
|
|
|
|
|
if (!dst_pitch)
|
|
|
|
dst_pitch = linepixels * dst_pixsize;
|
|
|
|
vaddr += clip_offset(clip, fb->pitches[0], fb->format->cpp[0]);
|
|
|
|
|
|
|
|
for (i = 0; i < lines; ++i) {
|
|
|
|
if (stmp)
|
|
|
|
sbuf = memcpy(stmp, vaddr, sbuf_len);
|
|
|
|
else
|
|
|
|
sbuf = vaddr;
|
|
|
|
xfrm_line(dbuf, sbuf, linepixels);
|
|
|
|
memcpy_toio(dst, dbuf, dbuf_len);
|
|
|
|
vaddr += fb->pitches[0];
|
|
|
|
dst += dst_pitch;
|
|
|
|
}
|
|
|
|
|
|
|
|
kfree(dbuf);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2022-08-08 20:54:05 +08:00
|
|
|
/* TODO: Make this function work with multi-plane formats. */
|
|
|
|
static int drm_fb_xfrm(struct iosys_map *dst,
|
|
|
|
const unsigned int *dst_pitch, const u8 *dst_pixsize,
|
2022-08-08 20:54:06 +08:00
|
|
|
const struct iosys_map *src, const struct drm_framebuffer *fb,
|
2022-08-08 20:54:05 +08:00
|
|
|
const struct drm_rect *clip, bool vaddr_cached_hint,
|
|
|
|
void (*xfrm_line)(void *dbuf, const void *sbuf, unsigned int npixels))
|
|
|
|
{
|
|
|
|
static const unsigned int default_dst_pitch[DRM_FORMAT_MAX_PLANES] = {
|
|
|
|
0, 0, 0, 0
|
|
|
|
};
|
|
|
|
|
|
|
|
if (!dst_pitch)
|
|
|
|
dst_pitch = default_dst_pitch;
|
|
|
|
|
2022-08-08 20:54:06 +08:00
|
|
|
/* TODO: handle src in I/O memory here */
|
2022-08-08 20:54:05 +08:00
|
|
|
if (dst[0].is_iomem)
|
|
|
|
return __drm_fb_xfrm_toio(dst[0].vaddr_iomem, dst_pitch[0], dst_pixsize[0],
|
2022-08-08 20:54:06 +08:00
|
|
|
src[0].vaddr, fb, clip, vaddr_cached_hint, xfrm_line);
|
2022-08-08 20:54:05 +08:00
|
|
|
else
|
|
|
|
return __drm_fb_xfrm(dst[0].vaddr, dst_pitch[0], dst_pixsize[0],
|
2022-08-08 20:54:06 +08:00
|
|
|
src[0].vaddr, fb, clip, vaddr_cached_hint, xfrm_line);
|
2022-08-08 20:54:05 +08:00
|
|
|
}
|
|
|
|
|
2019-04-05 17:52:15 +08:00
|
|
|
/**
|
|
|
|
* drm_fb_memcpy - Copy clip buffer
|
2022-08-08 20:53:55 +08:00
|
|
|
* @dst: Array of destination buffers
|
|
|
|
* @dst_pitch: Array of numbers of bytes between the start of two consecutive scanlines
|
|
|
|
* within @dst; can be NULL if scanlines are stored next to each other.
|
2022-08-08 20:54:06 +08:00
|
|
|
* @src: Array of source buffers
|
2019-04-05 17:52:15 +08:00
|
|
|
* @fb: DRM framebuffer
|
|
|
|
* @clip: Clip rectangle area to copy
|
2019-04-05 17:52:16 +08:00
|
|
|
*
|
2022-08-08 20:53:55 +08:00
|
|
|
* This function copies parts of a framebuffer to display memory. Destination and
|
|
|
|
* framebuffer formats must match. No conversion takes place. The parameters @dst,
|
2022-08-08 20:54:06 +08:00
|
|
|
* @dst_pitch and @src refer to arrays. Each array must have at least as many entries
|
2022-08-08 20:53:55 +08:00
|
|
|
* as there are planes in @fb's format. Each entry stores the value for the format's
|
|
|
|
* respective color plane at the same index.
|
2019-04-05 17:52:16 +08:00
|
|
|
*
|
2022-08-08 20:53:55 +08:00
|
|
|
* This function does not apply clipping on @dst (i.e. the destination is at the
|
|
|
|
* top-left corner).
|
2019-04-05 17:52:16 +08:00
|
|
|
*/
|
2022-08-08 20:53:55 +08:00
|
|
|
void drm_fb_memcpy(struct iosys_map *dst, const unsigned int *dst_pitch,
|
2022-08-08 20:54:06 +08:00
|
|
|
const struct iosys_map *src, const struct drm_framebuffer *fb,
|
2022-08-08 20:53:55 +08:00
|
|
|
const struct drm_rect *clip)
|
2019-04-05 17:52:16 +08:00
|
|
|
{
|
2022-08-08 20:53:55 +08:00
|
|
|
static const unsigned int default_dst_pitch[DRM_FORMAT_MAX_PLANES] = {
|
|
|
|
0, 0, 0, 0
|
|
|
|
};
|
2019-04-05 17:52:16 +08:00
|
|
|
|
2022-08-08 20:53:55 +08:00
|
|
|
const struct drm_format_info *format = fb->format;
|
|
|
|
unsigned int i, y, lines = drm_rect_height(clip);
|
2021-11-10 18:36:55 +08:00
|
|
|
|
2022-08-08 20:53:55 +08:00
|
|
|
if (!dst_pitch)
|
|
|
|
dst_pitch = default_dst_pitch;
|
|
|
|
|
|
|
|
for (i = 0; i < format->num_planes; ++i) {
|
|
|
|
unsigned int bpp_i = drm_format_info_bpp(format, i);
|
|
|
|
unsigned int cpp_i = DIV_ROUND_UP(bpp_i, 8);
|
|
|
|
size_t len_i = DIV_ROUND_UP(drm_rect_width(clip) * bpp_i, 8);
|
|
|
|
unsigned int dst_pitch_i = dst_pitch[i];
|
|
|
|
struct iosys_map dst_i = dst[i];
|
2022-08-08 20:54:06 +08:00
|
|
|
struct iosys_map src_i = src[i];
|
2022-08-08 20:53:55 +08:00
|
|
|
|
|
|
|
if (!dst_pitch_i)
|
|
|
|
dst_pitch_i = len_i;
|
|
|
|
|
2022-08-08 20:54:06 +08:00
|
|
|
iosys_map_incr(&src_i, clip_offset(clip, fb->pitches[i], cpp_i));
|
2022-08-08 20:53:55 +08:00
|
|
|
for (y = 0; y < lines; y++) {
|
2022-08-08 20:54:06 +08:00
|
|
|
/* TODO: handle src_i in I/O memory here */
|
|
|
|
iosys_map_memcpy_to(&dst_i, 0, src_i.vaddr, len_i);
|
|
|
|
iosys_map_incr(&src_i, fb->pitches[i]);
|
2022-08-08 20:53:55 +08:00
|
|
|
iosys_map_incr(&dst_i, dst_pitch_i);
|
|
|
|
}
|
2019-04-10 14:38:13 +08:00
|
|
|
}
|
2019-04-05 17:52:16 +08:00
|
|
|
}
|
2022-08-08 20:53:55 +08:00
|
|
|
EXPORT_SYMBOL(drm_fb_memcpy);
|
2019-04-05 17:52:16 +08:00
|
|
|
|
2022-04-27 22:14:06 +08:00
|
|
|
static void drm_fb_swab16_line(void *dbuf, const void *sbuf, unsigned int pixels)
|
|
|
|
{
|
|
|
|
u16 *dbuf16 = dbuf;
|
|
|
|
const u16 *sbuf16 = sbuf;
|
|
|
|
const u16 *send16 = sbuf16 + pixels;
|
|
|
|
|
|
|
|
while (sbuf16 < send16)
|
|
|
|
*dbuf16++ = swab16(*sbuf16++);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void drm_fb_swab32_line(void *dbuf, const void *sbuf, unsigned int pixels)
|
|
|
|
{
|
|
|
|
u32 *dbuf32 = dbuf;
|
|
|
|
const u32 *sbuf32 = sbuf;
|
|
|
|
const u32 *send32 = sbuf32 + pixels;
|
|
|
|
|
|
|
|
while (sbuf32 < send32)
|
|
|
|
*dbuf32++ = swab32(*sbuf32++);
|
|
|
|
}
|
|
|
|
|
2019-04-05 17:52:15 +08:00
|
|
|
/**
|
2020-05-09 22:16:16 +08:00
|
|
|
* drm_fb_swab - Swap bytes into clip buffer
|
2022-08-08 20:53:56 +08:00
|
|
|
* @dst: Array of destination buffers
|
|
|
|
* @dst_pitch: Array of numbers of bytes between the start of two consecutive scanlines
|
|
|
|
* within @dst; can be NULL if scanlines are stored next to each other.
|
2022-08-08 20:54:06 +08:00
|
|
|
* @src: Array of source buffers
|
2019-04-05 17:52:15 +08:00
|
|
|
* @fb: DRM framebuffer
|
|
|
|
* @clip: Clip rectangle area to copy
|
2020-05-09 22:16:16 +08:00
|
|
|
* @cached: Source buffer is mapped cached (eg. not write-combined)
|
|
|
|
*
|
2022-08-08 20:53:56 +08:00
|
|
|
* This function copies parts of a framebuffer to display memory and swaps per-pixel
|
|
|
|
* bytes during the process. Destination and framebuffer formats must match. The
|
2022-08-08 20:54:06 +08:00
|
|
|
* parameters @dst, @dst_pitch and @src refer to arrays. Each array must have at
|
2022-08-08 20:53:56 +08:00
|
|
|
* least as many entries as there are planes in @fb's format. Each entry stores the
|
|
|
|
* value for the format's respective color plane at the same index. If @cached is
|
|
|
|
* false a temporary buffer is used to cache one pixel line at a time to speed up
|
|
|
|
* slow uncached reads.
|
2020-05-09 22:16:16 +08:00
|
|
|
*
|
2022-08-08 20:53:56 +08:00
|
|
|
* This function does not apply clipping on @dst (i.e. the destination is at the
|
|
|
|
* top-left corner).
|
2019-04-05 17:52:15 +08:00
|
|
|
*/
|
2022-08-08 20:53:56 +08:00
|
|
|
void drm_fb_swab(struct iosys_map *dst, const unsigned int *dst_pitch,
|
2022-08-08 20:54:06 +08:00
|
|
|
const struct iosys_map *src, const struct drm_framebuffer *fb,
|
2022-08-08 20:53:56 +08:00
|
|
|
const struct drm_rect *clip, bool cached)
|
2019-04-05 17:52:15 +08:00
|
|
|
{
|
2022-08-08 20:53:56 +08:00
|
|
|
const struct drm_format_info *format = fb->format;
|
|
|
|
u8 cpp = DIV_ROUND_UP(drm_format_info_bpp(format, 0), 8);
|
|
|
|
void (*swab_line)(void *dbuf, const void *sbuf, unsigned int npixels);
|
2020-05-09 22:16:16 +08:00
|
|
|
|
2022-04-27 22:14:09 +08:00
|
|
|
switch (cpp) {
|
|
|
|
case 4:
|
2022-08-08 20:53:56 +08:00
|
|
|
swab_line = drm_fb_swab32_line;
|
2022-04-27 22:14:09 +08:00
|
|
|
break;
|
|
|
|
case 2:
|
2022-08-08 20:53:56 +08:00
|
|
|
swab_line = drm_fb_swab16_line;
|
2022-04-27 22:14:09 +08:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
drm_warn_once(fb->dev, "Format %p4cc has unsupported pixel size.\n",
|
2022-08-08 20:53:56 +08:00
|
|
|
&format->format);
|
|
|
|
return;
|
2022-08-08 20:54:05 +08:00
|
|
|
}
|
2022-08-08 20:53:56 +08:00
|
|
|
|
2022-08-08 20:54:06 +08:00
|
|
|
drm_fb_xfrm(dst, dst_pitch, &cpp, src, fb, clip, cached, swab_line);
|
2019-04-05 17:52:15 +08:00
|
|
|
}
|
2020-05-09 22:16:16 +08:00
|
|
|
EXPORT_SYMBOL(drm_fb_swab);
|
2019-04-05 17:52:15 +08:00
|
|
|
|
2022-04-27 22:14:09 +08:00
|
|
|
static void drm_fb_xrgb8888_to_rgb332_line(void *dbuf, const void *sbuf, unsigned int pixels)
|
2021-09-30 03:11:57 +08:00
|
|
|
{
|
2022-04-27 22:14:08 +08:00
|
|
|
u8 *dbuf8 = dbuf;
|
|
|
|
const __le32 *sbuf32 = sbuf;
|
2021-09-30 03:11:57 +08:00
|
|
|
unsigned int x;
|
|
|
|
u32 pix;
|
|
|
|
|
|
|
|
for (x = 0; x < pixels; x++) {
|
2022-04-27 22:14:08 +08:00
|
|
|
pix = le32_to_cpu(sbuf32[x]);
|
|
|
|
dbuf8[x] = ((pix & 0x00e00000) >> 16) |
|
|
|
|
((pix & 0x0000e000) >> 11) |
|
|
|
|
((pix & 0x000000c0) >> 6);
|
2021-09-30 03:11:57 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* drm_fb_xrgb8888_to_rgb332 - Convert XRGB8888 to RGB332 clip buffer
|
2022-08-08 20:53:57 +08:00
|
|
|
* @dst: Array of RGB332 destination buffers
|
|
|
|
* @dst_pitch: Array of numbers of bytes between the start of two consecutive scanlines
|
|
|
|
* within @dst; can be NULL if scanlines are stored next to each other.
|
2022-08-08 20:54:06 +08:00
|
|
|
* @src: Array of XRGB8888 source buffers
|
2021-09-30 03:11:57 +08:00
|
|
|
* @fb: DRM framebuffer
|
|
|
|
* @clip: Clip rectangle area to copy
|
|
|
|
*
|
2022-08-08 20:53:57 +08:00
|
|
|
* This function copies parts of a framebuffer to display memory and converts the
|
|
|
|
* color format during the process. Destination and framebuffer formats must match. The
|
2022-08-08 20:54:06 +08:00
|
|
|
* parameters @dst, @dst_pitch and @src refer to arrays. Each array must have at
|
2022-08-08 20:53:57 +08:00
|
|
|
* least as many entries as there are planes in @fb's format. Each entry stores the
|
|
|
|
* value for the format's respective color plane at the same index.
|
|
|
|
*
|
|
|
|
* This function does not apply clipping on @dst (i.e. the destination is at the
|
|
|
|
* top-left corner).
|
|
|
|
*
|
|
|
|
* Drivers can use this function for RGB332 devices that don't support XRGB8888 natively.
|
2021-09-30 03:11:57 +08:00
|
|
|
*/
|
2022-08-08 20:53:57 +08:00
|
|
|
void drm_fb_xrgb8888_to_rgb332(struct iosys_map *dst, const unsigned int *dst_pitch,
|
2022-08-08 20:54:06 +08:00
|
|
|
const struct iosys_map *src, const struct drm_framebuffer *fb,
|
2022-08-08 20:53:57 +08:00
|
|
|
const struct drm_rect *clip)
|
2021-09-30 03:11:57 +08:00
|
|
|
{
|
2022-08-08 20:54:05 +08:00
|
|
|
static const u8 dst_pixsize[DRM_FORMAT_MAX_PLANES] = {
|
|
|
|
1,
|
2022-08-08 20:53:57 +08:00
|
|
|
};
|
|
|
|
|
2022-08-08 20:54:06 +08:00
|
|
|
drm_fb_xfrm(dst, dst_pitch, dst_pixsize, src, fb, clip, false,
|
2022-08-08 20:54:05 +08:00
|
|
|
drm_fb_xrgb8888_to_rgb332_line);
|
2021-09-30 03:11:57 +08:00
|
|
|
}
|
|
|
|
EXPORT_SYMBOL(drm_fb_xrgb8888_to_rgb332);
|
|
|
|
|
2022-04-27 22:14:08 +08:00
|
|
|
static void drm_fb_xrgb8888_to_rgb565_line(void *dbuf, const void *sbuf, unsigned int pixels)
|
2019-04-05 17:52:15 +08:00
|
|
|
{
|
2023-01-02 19:29:18 +08:00
|
|
|
__le16 *dbuf16 = dbuf;
|
2022-07-09 02:21:08 +08:00
|
|
|
const __le32 *sbuf32 = sbuf;
|
2019-04-10 14:38:14 +08:00
|
|
|
unsigned int x;
|
|
|
|
u16 val16;
|
2022-07-09 02:21:08 +08:00
|
|
|
u32 pix;
|
2019-04-10 14:38:14 +08:00
|
|
|
|
|
|
|
for (x = 0; x < pixels; x++) {
|
2022-07-09 02:21:08 +08:00
|
|
|
pix = le32_to_cpu(sbuf32[x]);
|
|
|
|
val16 = ((pix & 0x00F80000) >> 8) |
|
|
|
|
((pix & 0x0000FC00) >> 5) |
|
|
|
|
((pix & 0x000000F8) >> 3);
|
2023-01-02 19:29:18 +08:00
|
|
|
dbuf16[x] = cpu_to_le16(val16);
|
2022-04-27 22:14:07 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-01-02 19:29:18 +08:00
|
|
|
/* TODO: implement this helper as conversion to RGB565|BIG_ENDIAN */
|
2022-04-27 22:14:08 +08:00
|
|
|
static void drm_fb_xrgb8888_to_rgb565_swab_line(void *dbuf, const void *sbuf,
|
2022-04-27 22:14:07 +08:00
|
|
|
unsigned int pixels)
|
|
|
|
{
|
2023-01-02 19:29:18 +08:00
|
|
|
__le16 *dbuf16 = dbuf;
|
2022-07-09 02:21:08 +08:00
|
|
|
const __le32 *sbuf32 = sbuf;
|
2022-04-27 22:14:07 +08:00
|
|
|
unsigned int x;
|
|
|
|
u16 val16;
|
2022-07-09 02:21:08 +08:00
|
|
|
u32 pix;
|
2022-04-27 22:14:07 +08:00
|
|
|
|
|
|
|
for (x = 0; x < pixels; x++) {
|
2022-07-09 02:21:08 +08:00
|
|
|
pix = le32_to_cpu(sbuf32[x]);
|
|
|
|
val16 = ((pix & 0x00F80000) >> 8) |
|
|
|
|
((pix & 0x0000FC00) >> 5) |
|
|
|
|
((pix & 0x000000F8) >> 3);
|
2023-01-02 19:29:18 +08:00
|
|
|
dbuf16[x] = cpu_to_le16(swab16(val16));
|
2019-04-05 17:52:15 +08:00
|
|
|
}
|
2019-04-05 17:52:17 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* drm_fb_xrgb8888_to_rgb565 - Convert XRGB8888 to RGB565 clip buffer
|
2022-08-08 20:53:58 +08:00
|
|
|
* @dst: Array of RGB565 destination buffers
|
|
|
|
* @dst_pitch: Array of numbers of bytes between the start of two consecutive scanlines
|
|
|
|
* within @dst; can be NULL if scanlines are stored next to each other.
|
2022-08-08 20:54:06 +08:00
|
|
|
* @src: Array of XRGB8888 source buffer
|
2019-04-05 17:52:17 +08:00
|
|
|
* @fb: DRM framebuffer
|
|
|
|
* @clip: Clip rectangle area to copy
|
2019-04-10 14:38:14 +08:00
|
|
|
* @swab: Swap bytes
|
2019-04-05 17:52:17 +08:00
|
|
|
*
|
2022-08-08 20:53:58 +08:00
|
|
|
* This function copies parts of a framebuffer to display memory and converts the
|
|
|
|
* color format during the process. Destination and framebuffer formats must match. The
|
2022-08-08 20:54:06 +08:00
|
|
|
* parameters @dst, @dst_pitch and @src refer to arrays. Each array must have at
|
2022-08-08 20:53:58 +08:00
|
|
|
* least as many entries as there are planes in @fb's format. Each entry stores the
|
|
|
|
* value for the format's respective color plane at the same index.
|
|
|
|
*
|
|
|
|
* This function does not apply clipping on @dst (i.e. the destination is at the
|
|
|
|
* top-left corner).
|
|
|
|
*
|
|
|
|
* Drivers can use this function for RGB565 devices that don't support XRGB8888 natively.
|
2019-04-05 17:52:17 +08:00
|
|
|
*/
|
2022-08-08 20:53:58 +08:00
|
|
|
void drm_fb_xrgb8888_to_rgb565(struct iosys_map *dst, const unsigned int *dst_pitch,
|
2022-08-08 20:54:06 +08:00
|
|
|
const struct iosys_map *src, const struct drm_framebuffer *fb,
|
2022-08-08 20:53:58 +08:00
|
|
|
const struct drm_rect *clip, bool swab)
|
2019-04-05 17:52:17 +08:00
|
|
|
{
|
2022-08-08 20:54:05 +08:00
|
|
|
static const u8 dst_pixsize[DRM_FORMAT_MAX_PLANES] = {
|
|
|
|
2,
|
2022-08-08 20:53:58 +08:00
|
|
|
};
|
2022-08-08 20:54:05 +08:00
|
|
|
|
2022-08-08 20:53:58 +08:00
|
|
|
void (*xfrm_line)(void *dbuf, const void *sbuf, unsigned int npixels);
|
|
|
|
|
2022-04-27 22:14:09 +08:00
|
|
|
if (swab)
|
2022-08-08 20:53:58 +08:00
|
|
|
xfrm_line = drm_fb_xrgb8888_to_rgb565_swab_line;
|
2022-04-27 22:14:09 +08:00
|
|
|
else
|
2022-08-08 20:53:58 +08:00
|
|
|
xfrm_line = drm_fb_xrgb8888_to_rgb565_line;
|
2019-04-05 17:52:15 +08:00
|
|
|
|
2022-08-08 20:54:06 +08:00
|
|
|
drm_fb_xfrm(dst, dst_pitch, dst_pixsize, src, fb, clip, false, xfrm_line);
|
2019-04-05 17:52:17 +08:00
|
|
|
}
|
2022-08-08 20:53:58 +08:00
|
|
|
EXPORT_SYMBOL(drm_fb_xrgb8888_to_rgb565);
|
2019-04-05 17:52:17 +08:00
|
|
|
|
2023-01-02 19:29:23 +08:00
|
|
|
static void drm_fb_xrgb8888_to_xrgb1555_line(void *dbuf, const void *sbuf, unsigned int pixels)
|
|
|
|
{
|
|
|
|
__le16 *dbuf16 = dbuf;
|
|
|
|
const __le32 *sbuf32 = sbuf;
|
|
|
|
unsigned int x;
|
|
|
|
u16 val16;
|
|
|
|
u32 pix;
|
|
|
|
|
|
|
|
for (x = 0; x < pixels; x++) {
|
|
|
|
pix = le32_to_cpu(sbuf32[x]);
|
|
|
|
val16 = ((pix & 0x00f80000) >> 9) |
|
|
|
|
((pix & 0x0000f800) >> 6) |
|
|
|
|
((pix & 0x000000f8) >> 3);
|
|
|
|
dbuf16[x] = cpu_to_le16(val16);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* drm_fb_xrgb8888_to_xrgb1555 - Convert XRGB8888 to XRGB1555 clip buffer
|
|
|
|
* @dst: Array of XRGB1555 destination buffers
|
|
|
|
* @dst_pitch: Array of numbers of bytes between the start of two consecutive scanlines
|
|
|
|
* within @dst; can be NULL if scanlines are stored next to each other.
|
|
|
|
* @src: Array of XRGB8888 source buffer
|
|
|
|
* @fb: DRM framebuffer
|
|
|
|
* @clip: Clip rectangle area to copy
|
|
|
|
*
|
|
|
|
* This function copies parts of a framebuffer to display memory and converts
|
|
|
|
* the color format during the process. The parameters @dst, @dst_pitch and
|
|
|
|
* @src refer to arrays. Each array must have at least as many entries as
|
|
|
|
* there are planes in @fb's format. Each entry stores the value for the
|
|
|
|
* format's respective color plane at the same index.
|
|
|
|
*
|
|
|
|
* This function does not apply clipping on @dst (i.e. the destination is at the
|
|
|
|
* top-left corner).
|
|
|
|
*
|
|
|
|
* Drivers can use this function for XRGB1555 devices that don't support
|
|
|
|
* XRGB8888 natively.
|
|
|
|
*/
|
|
|
|
void drm_fb_xrgb8888_to_xrgb1555(struct iosys_map *dst, const unsigned int *dst_pitch,
|
|
|
|
const struct iosys_map *src, const struct drm_framebuffer *fb,
|
|
|
|
const struct drm_rect *clip)
|
|
|
|
{
|
|
|
|
static const u8 dst_pixsize[DRM_FORMAT_MAX_PLANES] = {
|
|
|
|
2,
|
|
|
|
};
|
|
|
|
|
|
|
|
drm_fb_xfrm(dst, dst_pitch, dst_pixsize, src, fb, clip, false,
|
|
|
|
drm_fb_xrgb8888_to_xrgb1555_line);
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL(drm_fb_xrgb8888_to_xrgb1555);
|
|
|
|
|
|
|
|
static void drm_fb_xrgb8888_to_argb1555_line(void *dbuf, const void *sbuf, unsigned int pixels)
|
|
|
|
{
|
|
|
|
__le16 *dbuf16 = dbuf;
|
|
|
|
const __le32 *sbuf32 = sbuf;
|
|
|
|
unsigned int x;
|
|
|
|
u16 val16;
|
|
|
|
u32 pix;
|
|
|
|
|
|
|
|
for (x = 0; x < pixels; x++) {
|
|
|
|
pix = le32_to_cpu(sbuf32[x]);
|
|
|
|
val16 = BIT(15) | /* set alpha bit */
|
|
|
|
((pix & 0x00f80000) >> 9) |
|
|
|
|
((pix & 0x0000f800) >> 6) |
|
|
|
|
((pix & 0x000000f8) >> 3);
|
|
|
|
dbuf16[x] = cpu_to_le16(val16);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* drm_fb_xrgb8888_to_argb1555 - Convert XRGB8888 to ARGB1555 clip buffer
|
|
|
|
* @dst: Array of ARGB1555 destination buffers
|
|
|
|
* @dst_pitch: Array of numbers of bytes between the start of two consecutive scanlines
|
|
|
|
* within @dst; can be NULL if scanlines are stored next to each other.
|
|
|
|
* @src: Array of XRGB8888 source buffer
|
|
|
|
* @fb: DRM framebuffer
|
|
|
|
* @clip: Clip rectangle area to copy
|
|
|
|
*
|
|
|
|
* This function copies parts of a framebuffer to display memory and converts
|
|
|
|
* the color format during the process. The parameters @dst, @dst_pitch and
|
|
|
|
* @src refer to arrays. Each array must have at least as many entries as
|
|
|
|
* there are planes in @fb's format. Each entry stores the value for the
|
|
|
|
* format's respective color plane at the same index.
|
|
|
|
*
|
|
|
|
* This function does not apply clipping on @dst (i.e. the destination is at the
|
|
|
|
* top-left corner).
|
|
|
|
*
|
|
|
|
* Drivers can use this function for ARGB1555 devices that don't support
|
|
|
|
* XRGB8888 natively. It sets an opaque alpha channel as part of the conversion.
|
|
|
|
*/
|
|
|
|
void drm_fb_xrgb8888_to_argb1555(struct iosys_map *dst, const unsigned int *dst_pitch,
|
|
|
|
const struct iosys_map *src, const struct drm_framebuffer *fb,
|
|
|
|
const struct drm_rect *clip)
|
|
|
|
{
|
|
|
|
static const u8 dst_pixsize[DRM_FORMAT_MAX_PLANES] = {
|
|
|
|
2,
|
|
|
|
};
|
|
|
|
|
|
|
|
drm_fb_xfrm(dst, dst_pitch, dst_pixsize, src, fb, clip, false,
|
|
|
|
drm_fb_xrgb8888_to_argb1555_line);
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL(drm_fb_xrgb8888_to_argb1555);
|
|
|
|
|
|
|
|
static void drm_fb_xrgb8888_to_rgba5551_line(void *dbuf, const void *sbuf, unsigned int pixels)
|
|
|
|
{
|
|
|
|
__le16 *dbuf16 = dbuf;
|
|
|
|
const __le32 *sbuf32 = sbuf;
|
|
|
|
unsigned int x;
|
|
|
|
u16 val16;
|
|
|
|
u32 pix;
|
|
|
|
|
|
|
|
for (x = 0; x < pixels; x++) {
|
|
|
|
pix = le32_to_cpu(sbuf32[x]);
|
|
|
|
val16 = ((pix & 0x00f80000) >> 8) |
|
|
|
|
((pix & 0x0000f800) >> 5) |
|
|
|
|
((pix & 0x000000f8) >> 2) |
|
|
|
|
BIT(0); /* set alpha bit */
|
|
|
|
dbuf16[x] = cpu_to_le16(val16);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* drm_fb_xrgb8888_to_rgba5551 - Convert XRGB8888 to RGBA5551 clip buffer
|
|
|
|
* @dst: Array of RGBA5551 destination buffers
|
|
|
|
* @dst_pitch: Array of numbers of bytes between the start of two consecutive scanlines
|
|
|
|
* within @dst; can be NULL if scanlines are stored next to each other.
|
|
|
|
* @src: Array of XRGB8888 source buffer
|
|
|
|
* @fb: DRM framebuffer
|
|
|
|
* @clip: Clip rectangle area to copy
|
|
|
|
*
|
|
|
|
* This function copies parts of a framebuffer to display memory and converts
|
|
|
|
* the color format during the process. The parameters @dst, @dst_pitch and
|
|
|
|
* @src refer to arrays. Each array must have at least as many entries as
|
|
|
|
* there are planes in @fb's format. Each entry stores the value for the
|
|
|
|
* format's respective color plane at the same index.
|
|
|
|
*
|
|
|
|
* This function does not apply clipping on @dst (i.e. the destination is at the
|
|
|
|
* top-left corner).
|
|
|
|
*
|
|
|
|
* Drivers can use this function for RGBA5551 devices that don't support
|
|
|
|
* XRGB8888 natively. It sets an opaque alpha channel as part of the conversion.
|
|
|
|
*/
|
|
|
|
void drm_fb_xrgb8888_to_rgba5551(struct iosys_map *dst, const unsigned int *dst_pitch,
|
|
|
|
const struct iosys_map *src, const struct drm_framebuffer *fb,
|
|
|
|
const struct drm_rect *clip)
|
|
|
|
{
|
|
|
|
static const u8 dst_pixsize[DRM_FORMAT_MAX_PLANES] = {
|
|
|
|
2,
|
|
|
|
};
|
|
|
|
|
|
|
|
drm_fb_xfrm(dst, dst_pitch, dst_pixsize, src, fb, clip, false,
|
|
|
|
drm_fb_xrgb8888_to_rgba5551_line);
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL(drm_fb_xrgb8888_to_rgba5551);
|
|
|
|
|
2022-04-27 22:14:08 +08:00
|
|
|
static void drm_fb_xrgb8888_to_rgb888_line(void *dbuf, const void *sbuf, unsigned int pixels)
|
2019-04-05 17:52:18 +08:00
|
|
|
{
|
2022-04-27 22:14:08 +08:00
|
|
|
u8 *dbuf8 = dbuf;
|
2022-07-09 02:21:08 +08:00
|
|
|
const __le32 *sbuf32 = sbuf;
|
2019-04-10 14:38:15 +08:00
|
|
|
unsigned int x;
|
2022-07-09 02:21:08 +08:00
|
|
|
u32 pix;
|
2019-04-05 17:52:18 +08:00
|
|
|
|
2019-04-10 14:38:15 +08:00
|
|
|
for (x = 0; x < pixels; x++) {
|
2022-07-09 02:21:08 +08:00
|
|
|
pix = le32_to_cpu(sbuf32[x]);
|
2023-01-02 19:29:16 +08:00
|
|
|
/* write blue-green-red to output in little endianness */
|
2022-07-09 02:21:08 +08:00
|
|
|
*dbuf8++ = (pix & 0x000000FF) >> 0;
|
|
|
|
*dbuf8++ = (pix & 0x0000FF00) >> 8;
|
|
|
|
*dbuf8++ = (pix & 0x00FF0000) >> 16;
|
2019-04-05 17:52:18 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-09-30 03:11:58 +08:00
|
|
|
/**
|
|
|
|
* drm_fb_xrgb8888_to_rgb888 - Convert XRGB8888 to RGB888 clip buffer
|
2022-08-08 20:53:59 +08:00
|
|
|
* @dst: Array of RGB888 destination buffers
|
|
|
|
* @dst_pitch: Array of numbers of bytes between the start of two consecutive scanlines
|
|
|
|
* within @dst; can be NULL if scanlines are stored next to each other.
|
2022-08-08 20:54:06 +08:00
|
|
|
* @src: Array of XRGB8888 source buffers
|
2021-09-30 03:11:58 +08:00
|
|
|
* @fb: DRM framebuffer
|
|
|
|
* @clip: Clip rectangle area to copy
|
|
|
|
*
|
2022-08-08 20:53:59 +08:00
|
|
|
* This function copies parts of a framebuffer to display memory and converts the
|
|
|
|
* color format during the process. Destination and framebuffer formats must match. The
|
2022-08-08 20:54:06 +08:00
|
|
|
* parameters @dst, @dst_pitch and @src refer to arrays. Each array must have at
|
2022-08-08 20:53:59 +08:00
|
|
|
* least as many entries as there are planes in @fb's format. Each entry stores the
|
|
|
|
* value for the format's respective color plane at the same index.
|
|
|
|
*
|
|
|
|
* This function does not apply clipping on @dst (i.e. the destination is at the
|
|
|
|
* top-left corner).
|
2019-04-05 17:52:18 +08:00
|
|
|
*
|
|
|
|
* Drivers can use this function for RGB888 devices that don't natively
|
|
|
|
* support XRGB8888.
|
|
|
|
*/
|
2022-08-08 20:53:59 +08:00
|
|
|
void drm_fb_xrgb8888_to_rgb888(struct iosys_map *dst, const unsigned int *dst_pitch,
|
2022-08-08 20:54:06 +08:00
|
|
|
const struct iosys_map *src, const struct drm_framebuffer *fb,
|
2022-08-08 20:53:59 +08:00
|
|
|
const struct drm_rect *clip)
|
2019-04-05 17:52:18 +08:00
|
|
|
{
|
2022-08-08 20:54:05 +08:00
|
|
|
static const u8 dst_pixsize[DRM_FORMAT_MAX_PLANES] = {
|
|
|
|
3,
|
2022-08-08 20:53:59 +08:00
|
|
|
};
|
|
|
|
|
2022-08-08 20:54:06 +08:00
|
|
|
drm_fb_xfrm(dst, dst_pitch, dst_pixsize, src, fb, clip, false,
|
2022-08-08 20:54:05 +08:00
|
|
|
drm_fb_xrgb8888_to_rgb888_line);
|
2019-04-05 17:52:18 +08:00
|
|
|
}
|
2022-08-08 20:53:59 +08:00
|
|
|
EXPORT_SYMBOL(drm_fb_xrgb8888_to_rgb888);
|
2019-04-05 17:52:18 +08:00
|
|
|
|
2023-01-02 19:29:21 +08:00
|
|
|
static void drm_fb_xrgb8888_to_argb8888_line(void *dbuf, const void *sbuf, unsigned int pixels)
|
|
|
|
{
|
|
|
|
__le32 *dbuf32 = dbuf;
|
|
|
|
const __le32 *sbuf32 = sbuf;
|
|
|
|
unsigned int x;
|
|
|
|
u32 pix;
|
|
|
|
|
|
|
|
for (x = 0; x < pixels; x++) {
|
|
|
|
pix = le32_to_cpu(sbuf32[x]);
|
|
|
|
pix |= GENMASK(31, 24); /* fill alpha bits */
|
|
|
|
dbuf32[x] = cpu_to_le32(pix);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* drm_fb_xrgb8888_to_argb8888 - Convert XRGB8888 to ARGB8888 clip buffer
|
|
|
|
* @dst: Array of ARGB8888 destination buffers
|
|
|
|
* @dst_pitch: Array of numbers of bytes between the start of two consecutive scanlines
|
|
|
|
* within @dst; can be NULL if scanlines are stored next to each other.
|
|
|
|
* @src: Array of XRGB8888 source buffer
|
|
|
|
* @fb: DRM framebuffer
|
|
|
|
* @clip: Clip rectangle area to copy
|
|
|
|
*
|
|
|
|
* This function copies parts of a framebuffer to display memory and converts the
|
|
|
|
* color format during the process. The parameters @dst, @dst_pitch and @src refer
|
|
|
|
* to arrays. Each array must have at least as many entries as there are planes in
|
|
|
|
* @fb's format. Each entry stores the value for the format's respective color plane
|
|
|
|
* at the same index.
|
|
|
|
*
|
|
|
|
* This function does not apply clipping on @dst (i.e. the destination is at the
|
|
|
|
* top-left corner).
|
|
|
|
*
|
|
|
|
* Drivers can use this function for ARGB8888 devices that don't support XRGB8888
|
|
|
|
* natively. It sets an opaque alpha channel as part of the conversion.
|
|
|
|
*/
|
|
|
|
void drm_fb_xrgb8888_to_argb8888(struct iosys_map *dst, const unsigned int *dst_pitch,
|
|
|
|
const struct iosys_map *src, const struct drm_framebuffer *fb,
|
|
|
|
const struct drm_rect *clip)
|
|
|
|
{
|
|
|
|
static const u8 dst_pixsize[DRM_FORMAT_MAX_PLANES] = {
|
|
|
|
4,
|
|
|
|
};
|
|
|
|
|
|
|
|
drm_fb_xfrm(dst, dst_pitch, dst_pixsize, src, fb, clip, false,
|
|
|
|
drm_fb_xrgb8888_to_argb8888_line);
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL(drm_fb_xrgb8888_to_argb8888);
|
|
|
|
|
2023-01-21 01:31:01 +08:00
|
|
|
static void drm_fb_xrgb8888_to_abgr8888_line(void *dbuf, const void *sbuf, unsigned int pixels)
|
|
|
|
{
|
|
|
|
__le32 *dbuf32 = dbuf;
|
|
|
|
const __le32 *sbuf32 = sbuf;
|
|
|
|
unsigned int x;
|
|
|
|
u32 pix;
|
|
|
|
|
|
|
|
for (x = 0; x < pixels; x++) {
|
|
|
|
pix = le32_to_cpu(sbuf32[x]);
|
|
|
|
pix = ((pix & 0x00ff0000) >> 16) << 0 |
|
|
|
|
((pix & 0x0000ff00) >> 8) << 8 |
|
|
|
|
((pix & 0x000000ff) >> 0) << 16 |
|
|
|
|
GENMASK(31, 24); /* fill alpha bits */
|
|
|
|
*dbuf32++ = cpu_to_le32(pix);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void drm_fb_xrgb8888_to_abgr8888(struct iosys_map *dst, const unsigned int *dst_pitch,
|
|
|
|
const struct iosys_map *src,
|
|
|
|
const struct drm_framebuffer *fb,
|
|
|
|
const struct drm_rect *clip)
|
|
|
|
{
|
|
|
|
static const u8 dst_pixsize[DRM_FORMAT_MAX_PLANES] = {
|
|
|
|
4,
|
|
|
|
};
|
|
|
|
|
|
|
|
drm_fb_xfrm(dst, dst_pitch, dst_pixsize, src, fb, clip, false,
|
|
|
|
drm_fb_xrgb8888_to_abgr8888_line);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void drm_fb_xrgb8888_to_xbgr8888_line(void *dbuf, const void *sbuf, unsigned int pixels)
|
|
|
|
{
|
|
|
|
__le32 *dbuf32 = dbuf;
|
|
|
|
const __le32 *sbuf32 = sbuf;
|
|
|
|
unsigned int x;
|
|
|
|
u32 pix;
|
|
|
|
|
|
|
|
for (x = 0; x < pixels; x++) {
|
|
|
|
pix = le32_to_cpu(sbuf32[x]);
|
|
|
|
pix = ((pix & 0x00ff0000) >> 16) << 0 |
|
|
|
|
((pix & 0x0000ff00) >> 8) << 8 |
|
|
|
|
((pix & 0x000000ff) >> 0) << 16 |
|
|
|
|
((pix & 0xff000000) >> 24) << 24;
|
|
|
|
*dbuf32++ = cpu_to_le32(pix);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void drm_fb_xrgb8888_to_xbgr8888(struct iosys_map *dst, const unsigned int *dst_pitch,
|
|
|
|
const struct iosys_map *src,
|
|
|
|
const struct drm_framebuffer *fb,
|
|
|
|
const struct drm_rect *clip)
|
|
|
|
{
|
|
|
|
static const u8 dst_pixsize[DRM_FORMAT_MAX_PLANES] = {
|
|
|
|
4,
|
|
|
|
};
|
|
|
|
|
|
|
|
drm_fb_xfrm(dst, dst_pitch, dst_pixsize, src, fb, clip, false,
|
|
|
|
drm_fb_xrgb8888_to_xbgr8888_line);
|
|
|
|
}
|
|
|
|
|
2022-04-27 22:14:08 +08:00
|
|
|
static void drm_fb_xrgb8888_to_xrgb2101010_line(void *dbuf, const void *sbuf, unsigned int pixels)
|
2021-12-12 14:24:06 +08:00
|
|
|
{
|
2022-07-09 02:21:08 +08:00
|
|
|
__le32 *dbuf32 = dbuf;
|
|
|
|
const __le32 *sbuf32 = sbuf;
|
2021-12-12 14:24:06 +08:00
|
|
|
unsigned int x;
|
|
|
|
u32 val32;
|
2022-07-09 02:21:08 +08:00
|
|
|
u32 pix;
|
2021-12-12 14:24:06 +08:00
|
|
|
|
|
|
|
for (x = 0; x < pixels; x++) {
|
2022-07-09 02:21:08 +08:00
|
|
|
pix = le32_to_cpu(sbuf32[x]);
|
|
|
|
val32 = ((pix & 0x000000FF) << 2) |
|
|
|
|
((pix & 0x0000FF00) << 4) |
|
|
|
|
((pix & 0x00FF0000) << 6);
|
|
|
|
pix = val32 | ((val32 >> 8) & 0x00300C03);
|
|
|
|
*dbuf32++ = cpu_to_le32(pix);
|
2021-12-12 14:24:06 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2022-08-08 20:54:02 +08:00
|
|
|
* drm_fb_xrgb8888_to_xrgb2101010 - Convert XRGB8888 to XRGB2101010 clip buffer
|
|
|
|
* @dst: Array of XRGB2101010 destination buffers
|
|
|
|
* @dst_pitch: Array of numbers of bytes between the start of two consecutive scanlines
|
|
|
|
* within @dst; can be NULL if scanlines are stored next to each other.
|
2022-08-08 20:54:06 +08:00
|
|
|
* @src: Array of XRGB8888 source buffers
|
2021-12-12 14:24:06 +08:00
|
|
|
* @fb: DRM framebuffer
|
|
|
|
* @clip: Clip rectangle area to copy
|
|
|
|
*
|
2022-08-08 20:54:02 +08:00
|
|
|
* This function copies parts of a framebuffer to display memory and converts the
|
|
|
|
* color format during the process. Destination and framebuffer formats must match. The
|
2022-08-08 20:54:06 +08:00
|
|
|
* parameters @dst, @dst_pitch and @src refer to arrays. Each array must have at
|
2022-08-08 20:54:02 +08:00
|
|
|
* least as many entries as there are planes in @fb's format. Each entry stores the
|
|
|
|
* value for the format's respective color plane at the same index.
|
|
|
|
*
|
|
|
|
* This function does not apply clipping on @dst (i.e. the destination is at the
|
|
|
|
* top-left corner).
|
|
|
|
*
|
|
|
|
* Drivers can use this function for XRGB2101010 devices that don't support XRGB8888
|
|
|
|
* natively.
|
2021-12-12 14:24:06 +08:00
|
|
|
*/
|
2022-08-08 20:54:02 +08:00
|
|
|
void drm_fb_xrgb8888_to_xrgb2101010(struct iosys_map *dst, const unsigned int *dst_pitch,
|
2022-08-08 20:54:06 +08:00
|
|
|
const struct iosys_map *src, const struct drm_framebuffer *fb,
|
2022-08-08 20:54:02 +08:00
|
|
|
const struct drm_rect *clip)
|
2021-12-12 14:24:06 +08:00
|
|
|
{
|
2022-08-08 20:54:05 +08:00
|
|
|
static const u8 dst_pixsize[DRM_FORMAT_MAX_PLANES] = {
|
|
|
|
4,
|
2022-08-08 20:54:02 +08:00
|
|
|
};
|
|
|
|
|
2022-08-08 20:54:06 +08:00
|
|
|
drm_fb_xfrm(dst, dst_pitch, dst_pixsize, src, fb, clip, false,
|
2022-08-08 20:54:05 +08:00
|
|
|
drm_fb_xrgb8888_to_xrgb2101010_line);
|
2021-12-12 14:24:06 +08:00
|
|
|
}
|
2022-09-26 16:08:36 +08:00
|
|
|
EXPORT_SYMBOL(drm_fb_xrgb8888_to_xrgb2101010);
|
2021-12-12 14:24:06 +08:00
|
|
|
|
2023-01-02 19:29:22 +08:00
|
|
|
static void drm_fb_xrgb8888_to_argb2101010_line(void *dbuf, const void *sbuf, unsigned int pixels)
|
|
|
|
{
|
|
|
|
__le32 *dbuf32 = dbuf;
|
|
|
|
const __le32 *sbuf32 = sbuf;
|
|
|
|
unsigned int x;
|
|
|
|
u32 val32;
|
|
|
|
u32 pix;
|
|
|
|
|
|
|
|
for (x = 0; x < pixels; x++) {
|
|
|
|
pix = le32_to_cpu(sbuf32[x]);
|
|
|
|
val32 = ((pix & 0x000000ff) << 2) |
|
|
|
|
((pix & 0x0000ff00) << 4) |
|
|
|
|
((pix & 0x00ff0000) << 6);
|
|
|
|
pix = GENMASK(31, 30) | /* set alpha bits */
|
|
|
|
val32 | ((val32 >> 8) & 0x00300c03);
|
|
|
|
*dbuf32++ = cpu_to_le32(pix);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* drm_fb_xrgb8888_to_argb2101010 - Convert XRGB8888 to ARGB2101010 clip buffer
|
|
|
|
* @dst: Array of ARGB2101010 destination buffers
|
|
|
|
* @dst_pitch: Array of numbers of bytes between the start of two consecutive scanlines
|
|
|
|
* within @dst; can be NULL if scanlines are stored next to each other.
|
|
|
|
* @src: Array of XRGB8888 source buffers
|
|
|
|
* @fb: DRM framebuffer
|
|
|
|
* @clip: Clip rectangle area to copy
|
|
|
|
*
|
|
|
|
* This function copies parts of a framebuffer to display memory and converts
|
|
|
|
* the color format during the process. The parameters @dst, @dst_pitch and
|
|
|
|
* @src refer to arrays. Each array must have at least as many entries as
|
|
|
|
* there are planes in @fb's format. Each entry stores the value for the
|
|
|
|
* format's respective color plane at the same index.
|
|
|
|
*
|
|
|
|
* This function does not apply clipping on @dst (i.e. the destination is at the
|
|
|
|
* top-left corner).
|
|
|
|
*
|
|
|
|
* Drivers can use this function for ARGB2101010 devices that don't support XRGB8888
|
|
|
|
* natively.
|
|
|
|
*/
|
|
|
|
void drm_fb_xrgb8888_to_argb2101010(struct iosys_map *dst, const unsigned int *dst_pitch,
|
|
|
|
const struct iosys_map *src, const struct drm_framebuffer *fb,
|
|
|
|
const struct drm_rect *clip)
|
|
|
|
{
|
|
|
|
static const u8 dst_pixsize[DRM_FORMAT_MAX_PLANES] = {
|
|
|
|
4,
|
|
|
|
};
|
|
|
|
|
|
|
|
drm_fb_xfrm(dst, dst_pitch, dst_pixsize, src, fb, clip, false,
|
|
|
|
drm_fb_xrgb8888_to_argb2101010_line);
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL(drm_fb_xrgb8888_to_argb2101010);
|
|
|
|
|
2022-04-27 22:14:08 +08:00
|
|
|
static void drm_fb_xrgb8888_to_gray8_line(void *dbuf, const void *sbuf, unsigned int pixels)
|
2022-02-14 21:37:05 +08:00
|
|
|
{
|
2022-04-27 22:14:08 +08:00
|
|
|
u8 *dbuf8 = dbuf;
|
2022-07-09 02:21:08 +08:00
|
|
|
const __le32 *sbuf32 = sbuf;
|
2022-02-14 21:37:05 +08:00
|
|
|
unsigned int x;
|
|
|
|
|
|
|
|
for (x = 0; x < pixels; x++) {
|
2022-07-09 02:21:08 +08:00
|
|
|
u32 pix = le32_to_cpu(sbuf32[x]);
|
|
|
|
u8 r = (pix & 0x00ff0000) >> 16;
|
|
|
|
u8 g = (pix & 0x0000ff00) >> 8;
|
|
|
|
u8 b = pix & 0x000000ff;
|
2022-02-14 21:37:05 +08:00
|
|
|
|
|
|
|
/* ITU BT.601: Y = 0.299 R + 0.587 G + 0.114 B */
|
2022-04-27 22:14:08 +08:00
|
|
|
*dbuf8++ = (3 * r + 6 * g + b) / 10;
|
2022-02-14 21:37:05 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-04-05 17:52:15 +08:00
|
|
|
/**
|
|
|
|
* drm_fb_xrgb8888_to_gray8 - Convert XRGB8888 to grayscale
|
2022-08-08 20:54:03 +08:00
|
|
|
* @dst: Array of 8-bit grayscale destination buffers
|
|
|
|
* @dst_pitch: Array of numbers of bytes between the start of two consecutive scanlines
|
|
|
|
* within @dst; can be NULL if scanlines are stored next to each other.
|
2022-08-08 20:54:06 +08:00
|
|
|
* @src: Array of XRGB8888 source buffers
|
2019-04-05 17:52:15 +08:00
|
|
|
* @fb: DRM framebuffer
|
|
|
|
* @clip: Clip rectangle area to copy
|
|
|
|
*
|
2022-08-08 20:54:03 +08:00
|
|
|
* This function copies parts of a framebuffer to display memory and converts the
|
|
|
|
* color format during the process. Destination and framebuffer formats must match. The
|
2022-08-08 20:54:06 +08:00
|
|
|
* parameters @dst, @dst_pitch and @src refer to arrays. Each array must have at
|
2022-08-08 20:54:03 +08:00
|
|
|
* least as many entries as there are planes in @fb's format. Each entry stores the
|
|
|
|
* value for the format's respective color plane at the same index.
|
2019-04-05 17:52:15 +08:00
|
|
|
*
|
2022-08-08 20:54:03 +08:00
|
|
|
* This function does not apply clipping on @dst (i.e. the destination is at the
|
|
|
|
* top-left corner).
|
2019-04-05 17:52:15 +08:00
|
|
|
*
|
2022-08-08 20:54:03 +08:00
|
|
|
* DRM doesn't have native monochrome or grayscale support. Drivers can use this
|
|
|
|
* function for grayscale devices that don't support XRGB8888 natively.Such
|
|
|
|
* drivers can announce the commonly supported XR24 format to userspace and use
|
|
|
|
* this function to convert to the native format. Monochrome drivers will use the
|
|
|
|
* most significant bit, where 1 means foreground color and 0 background color.
|
|
|
|
* ITU BT.601 is being used for the RGB -> luma (brightness) conversion.
|
2019-04-05 17:52:15 +08:00
|
|
|
*/
|
2022-08-08 20:54:03 +08:00
|
|
|
void drm_fb_xrgb8888_to_gray8(struct iosys_map *dst, const unsigned int *dst_pitch,
|
2022-08-08 20:54:06 +08:00
|
|
|
const struct iosys_map *src, const struct drm_framebuffer *fb,
|
2022-08-08 20:54:03 +08:00
|
|
|
const struct drm_rect *clip)
|
2019-04-05 17:52:15 +08:00
|
|
|
{
|
2022-08-08 20:54:05 +08:00
|
|
|
static const u8 dst_pixsize[DRM_FORMAT_MAX_PLANES] = {
|
|
|
|
1,
|
2022-08-08 20:54:03 +08:00
|
|
|
};
|
|
|
|
|
2022-08-08 20:54:06 +08:00
|
|
|
drm_fb_xfrm(dst, dst_pitch, dst_pixsize, src, fb, clip, false,
|
2022-08-08 20:54:05 +08:00
|
|
|
drm_fb_xrgb8888_to_gray8_line);
|
2019-04-05 17:52:15 +08:00
|
|
|
}
|
|
|
|
EXPORT_SYMBOL(drm_fb_xrgb8888_to_gray8);
|
|
|
|
|
2021-04-30 18:58:33 +08:00
|
|
|
/**
|
2022-08-08 20:53:54 +08:00
|
|
|
* drm_fb_blit - Copy parts of a framebuffer to display memory
|
|
|
|
* @dst: Array of display-memory addresses to copy to
|
|
|
|
* @dst_pitch: Array of numbers of bytes between the start of two consecutive scanlines
|
|
|
|
* within @dst; can be NULL if scanlines are stored next to each other.
|
2021-04-30 18:58:33 +08:00
|
|
|
* @dst_format: FOURCC code of the display's color format
|
2022-08-08 20:54:06 +08:00
|
|
|
* @src: The framebuffer memory to copy from
|
2021-04-30 18:58:33 +08:00
|
|
|
* @fb: The framebuffer to copy from
|
|
|
|
* @clip: Clip rectangle area to copy
|
|
|
|
*
|
|
|
|
* This function copies parts of a framebuffer to display memory. If the
|
|
|
|
* formats of the display and the framebuffer mismatch, the blit function
|
2022-08-08 20:53:54 +08:00
|
|
|
* will attempt to convert between them during the process. The parameters @dst,
|
2022-08-08 20:54:06 +08:00
|
|
|
* @dst_pitch and @src refer to arrays. Each array must have at least as many
|
2022-08-08 20:53:54 +08:00
|
|
|
* entries as there are planes in @dst_format's format. Each entry stores the
|
|
|
|
* value for the format's respective color plane at the same index.
|
|
|
|
*
|
|
|
|
* This function does not apply clipping on @dst (i.e. the destination is at the
|
|
|
|
* top-left corner).
|
2021-04-30 18:58:33 +08:00
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
* 0 on success, or
|
|
|
|
* -EINVAL if the color-format conversion failed, or
|
|
|
|
* a negative error code otherwise.
|
|
|
|
*/
|
2022-08-08 20:53:54 +08:00
|
|
|
int drm_fb_blit(struct iosys_map *dst, const unsigned int *dst_pitch, uint32_t dst_format,
|
2022-08-08 20:54:06 +08:00
|
|
|
const struct iosys_map *src, const struct drm_framebuffer *fb,
|
2022-08-08 20:53:54 +08:00
|
|
|
const struct drm_rect *clip)
|
2021-04-30 18:58:33 +08:00
|
|
|
{
|
|
|
|
uint32_t fb_format = fb->format->format;
|
|
|
|
|
2023-01-02 19:29:20 +08:00
|
|
|
if (fb_format == dst_format) {
|
2022-08-08 20:54:06 +08:00
|
|
|
drm_fb_memcpy(dst, dst_pitch, src, fb, clip);
|
2021-04-30 18:58:33 +08:00
|
|
|
return 0;
|
2023-01-02 19:29:20 +08:00
|
|
|
} else if (fb_format == (dst_format | DRM_FORMAT_BIG_ENDIAN)) {
|
|
|
|
drm_fb_swab(dst, dst_pitch, src, fb, clip, false);
|
|
|
|
return 0;
|
|
|
|
} else if (fb_format == (dst_format & ~DRM_FORMAT_BIG_ENDIAN)) {
|
|
|
|
drm_fb_swab(dst, dst_pitch, src, fb, clip, false);
|
|
|
|
return 0;
|
|
|
|
} else if (fb_format == DRM_FORMAT_XRGB8888) {
|
|
|
|
if (dst_format == DRM_FORMAT_RGB565) {
|
2022-08-08 20:54:06 +08:00
|
|
|
drm_fb_xrgb8888_to_rgb565(dst, dst_pitch, src, fb, clip, false);
|
2021-04-30 18:58:33 +08:00
|
|
|
return 0;
|
2023-01-02 19:29:23 +08:00
|
|
|
} else if (dst_format == DRM_FORMAT_XRGB1555) {
|
|
|
|
drm_fb_xrgb8888_to_xrgb1555(dst, dst_pitch, src, fb, clip);
|
|
|
|
return 0;
|
|
|
|
} else if (dst_format == DRM_FORMAT_ARGB1555) {
|
|
|
|
drm_fb_xrgb8888_to_argb1555(dst, dst_pitch, src, fb, clip);
|
|
|
|
return 0;
|
|
|
|
} else if (dst_format == DRM_FORMAT_RGBA5551) {
|
|
|
|
drm_fb_xrgb8888_to_rgba5551(dst, dst_pitch, src, fb, clip);
|
|
|
|
return 0;
|
2023-01-02 19:29:20 +08:00
|
|
|
} else if (dst_format == DRM_FORMAT_RGB888) {
|
2022-08-08 20:54:06 +08:00
|
|
|
drm_fb_xrgb8888_to_rgb888(dst, dst_pitch, src, fb, clip);
|
2021-04-30 18:58:33 +08:00
|
|
|
return 0;
|
2023-01-02 19:29:21 +08:00
|
|
|
} else if (dst_format == DRM_FORMAT_ARGB8888) {
|
|
|
|
drm_fb_xrgb8888_to_argb8888(dst, dst_pitch, src, fb, clip);
|
|
|
|
return 0;
|
2023-01-21 01:31:01 +08:00
|
|
|
} else if (dst_format == DRM_FORMAT_XBGR8888) {
|
|
|
|
drm_fb_xrgb8888_to_xbgr8888(dst, dst_pitch, src, fb, clip);
|
|
|
|
return 0;
|
|
|
|
} else if (dst_format == DRM_FORMAT_ABGR8888) {
|
|
|
|
drm_fb_xrgb8888_to_abgr8888(dst, dst_pitch, src, fb, clip);
|
|
|
|
return 0;
|
2023-01-02 19:29:20 +08:00
|
|
|
} else if (dst_format == DRM_FORMAT_XRGB2101010) {
|
|
|
|
drm_fb_xrgb8888_to_xrgb2101010(dst, dst_pitch, src, fb, clip);
|
2022-04-25 15:59:38 +08:00
|
|
|
return 0;
|
2023-01-02 19:29:22 +08:00
|
|
|
} else if (dst_format == DRM_FORMAT_ARGB2101010) {
|
|
|
|
drm_fb_xrgb8888_to_argb2101010(dst, dst_pitch, src, fb, clip);
|
|
|
|
return 0;
|
2023-01-02 19:29:20 +08:00
|
|
|
} else if (dst_format == DRM_FORMAT_BGRX8888) {
|
|
|
|
drm_fb_swab(dst, dst_pitch, src, fb, clip, false);
|
2022-04-25 15:59:39 +08:00
|
|
|
return 0;
|
2022-04-25 15:59:38 +08:00
|
|
|
}
|
2021-04-30 18:58:33 +08:00
|
|
|
}
|
|
|
|
|
2022-04-25 15:59:37 +08:00
|
|
|
drm_warn_once(fb->dev, "No conversion helper from %p4cc to %p4cc found.\n",
|
|
|
|
&fb_format, &dst_format);
|
|
|
|
|
2021-04-30 18:58:33 +08:00
|
|
|
return -EINVAL;
|
|
|
|
}
|
2022-08-08 20:53:54 +08:00
|
|
|
EXPORT_SYMBOL(drm_fb_blit);
|
2022-02-14 21:37:06 +08:00
|
|
|
|
2022-04-27 22:14:08 +08:00
|
|
|
static void drm_fb_gray8_to_mono_line(void *dbuf, const void *sbuf, unsigned int pixels)
|
drm/format-helper: Fix XRGB888 to monochrome conversion
The conversion functions drm_fb_xrgb8888_to_mono() and
drm_fb_gray8_to_mono_line() do not behave correctly when the
horizontal boundaries of the clip rectangle are not multiples of 8:
a. When x1 % 8 != 0, the calculated pitch is not correct,
b. When x2 % 8 != 0, the pixel data for the last byte is wrong.
Simplify the code and fix (a) by:
1. Removing start_offset, and always storing the first pixel in the
first bit of the monochrome destination buffer.
Drivers that require the first pixel in a byte to be located at an
x-coordinate that is a multiple of 8 can always align the clip
rectangle before calling drm_fb_xrgb8888_to_mono().
Note that:
- The ssd130x driver does not need the alignment, as the
monochrome buffer is a temporary format,
- The repaper driver always updates the full screen, so the clip
rectangle is always aligned.
2. Passing the number of pixels to drm_fb_gray8_to_mono_line(),
instead of the number of bytes, and the number of pixels in the
last byte.
Fix (b) by explicitly setting the target bit, instead of always setting
bit 7 and shifting the value in each loop iteration.
Remove the bogus pitch check, which operates on bytes instead of pixels,
and triggers when e.g. flashing the cursor on a text console with a font
that is 8 pixels wide.
Drop the confusing comment about scanlines, as a pitch in bytes always
contains a multiple of 8 pixels.
While at it, use the drm_rect_height() helper instead of open-coding the
same operation.
Update the comments accordingly.
Fixes: bcf8b616deb87941 ("drm/format-helper: Add drm_fb_xrgb8888_to_mono_reversed()")
Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
Acked-by: Javier Martinez Canillas <javierm@redhat.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20220317081830.1211400-3-geert@linux-m68k.org
2022-03-17 16:18:27 +08:00
|
|
|
{
|
2022-04-27 22:14:08 +08:00
|
|
|
u8 *dbuf8 = dbuf;
|
|
|
|
const u8 *sbuf8 = sbuf;
|
|
|
|
|
drm/format-helper: Fix XRGB888 to monochrome conversion
The conversion functions drm_fb_xrgb8888_to_mono() and
drm_fb_gray8_to_mono_line() do not behave correctly when the
horizontal boundaries of the clip rectangle are not multiples of 8:
a. When x1 % 8 != 0, the calculated pitch is not correct,
b. When x2 % 8 != 0, the pixel data for the last byte is wrong.
Simplify the code and fix (a) by:
1. Removing start_offset, and always storing the first pixel in the
first bit of the monochrome destination buffer.
Drivers that require the first pixel in a byte to be located at an
x-coordinate that is a multiple of 8 can always align the clip
rectangle before calling drm_fb_xrgb8888_to_mono().
Note that:
- The ssd130x driver does not need the alignment, as the
monochrome buffer is a temporary format,
- The repaper driver always updates the full screen, so the clip
rectangle is always aligned.
2. Passing the number of pixels to drm_fb_gray8_to_mono_line(),
instead of the number of bytes, and the number of pixels in the
last byte.
Fix (b) by explicitly setting the target bit, instead of always setting
bit 7 and shifting the value in each loop iteration.
Remove the bogus pitch check, which operates on bytes instead of pixels,
and triggers when e.g. flashing the cursor on a text console with a font
that is 8 pixels wide.
Drop the confusing comment about scanlines, as a pitch in bytes always
contains a multiple of 8 pixels.
While at it, use the drm_rect_height() helper instead of open-coding the
same operation.
Update the comments accordingly.
Fixes: bcf8b616deb87941 ("drm/format-helper: Add drm_fb_xrgb8888_to_mono_reversed()")
Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
Acked-by: Javier Martinez Canillas <javierm@redhat.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20220317081830.1211400-3-geert@linux-m68k.org
2022-03-17 16:18:27 +08:00
|
|
|
while (pixels) {
|
|
|
|
unsigned int i, bits = min(pixels, 8U);
|
|
|
|
u8 byte = 0;
|
2022-02-14 21:37:06 +08:00
|
|
|
|
drm/format-helper: Fix XRGB888 to monochrome conversion
The conversion functions drm_fb_xrgb8888_to_mono() and
drm_fb_gray8_to_mono_line() do not behave correctly when the
horizontal boundaries of the clip rectangle are not multiples of 8:
a. When x1 % 8 != 0, the calculated pitch is not correct,
b. When x2 % 8 != 0, the pixel data for the last byte is wrong.
Simplify the code and fix (a) by:
1. Removing start_offset, and always storing the first pixel in the
first bit of the monochrome destination buffer.
Drivers that require the first pixel in a byte to be located at an
x-coordinate that is a multiple of 8 can always align the clip
rectangle before calling drm_fb_xrgb8888_to_mono().
Note that:
- The ssd130x driver does not need the alignment, as the
monochrome buffer is a temporary format,
- The repaper driver always updates the full screen, so the clip
rectangle is always aligned.
2. Passing the number of pixels to drm_fb_gray8_to_mono_line(),
instead of the number of bytes, and the number of pixels in the
last byte.
Fix (b) by explicitly setting the target bit, instead of always setting
bit 7 and shifting the value in each loop iteration.
Remove the bogus pitch check, which operates on bytes instead of pixels,
and triggers when e.g. flashing the cursor on a text console with a font
that is 8 pixels wide.
Drop the confusing comment about scanlines, as a pitch in bytes always
contains a multiple of 8 pixels.
While at it, use the drm_rect_height() helper instead of open-coding the
same operation.
Update the comments accordingly.
Fixes: bcf8b616deb87941 ("drm/format-helper: Add drm_fb_xrgb8888_to_mono_reversed()")
Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
Acked-by: Javier Martinez Canillas <javierm@redhat.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20220317081830.1211400-3-geert@linux-m68k.org
2022-03-17 16:18:27 +08:00
|
|
|
for (i = 0; i < bits; i++, pixels--) {
|
2022-04-27 22:14:08 +08:00
|
|
|
if (*sbuf8++ >= 128)
|
drm/format-helper: Fix XRGB888 to monochrome conversion
The conversion functions drm_fb_xrgb8888_to_mono() and
drm_fb_gray8_to_mono_line() do not behave correctly when the
horizontal boundaries of the clip rectangle are not multiples of 8:
a. When x1 % 8 != 0, the calculated pitch is not correct,
b. When x2 % 8 != 0, the pixel data for the last byte is wrong.
Simplify the code and fix (a) by:
1. Removing start_offset, and always storing the first pixel in the
first bit of the monochrome destination buffer.
Drivers that require the first pixel in a byte to be located at an
x-coordinate that is a multiple of 8 can always align the clip
rectangle before calling drm_fb_xrgb8888_to_mono().
Note that:
- The ssd130x driver does not need the alignment, as the
monochrome buffer is a temporary format,
- The repaper driver always updates the full screen, so the clip
rectangle is always aligned.
2. Passing the number of pixels to drm_fb_gray8_to_mono_line(),
instead of the number of bytes, and the number of pixels in the
last byte.
Fix (b) by explicitly setting the target bit, instead of always setting
bit 7 and shifting the value in each loop iteration.
Remove the bogus pitch check, which operates on bytes instead of pixels,
and triggers when e.g. flashing the cursor on a text console with a font
that is 8 pixels wide.
Drop the confusing comment about scanlines, as a pitch in bytes always
contains a multiple of 8 pixels.
While at it, use the drm_rect_height() helper instead of open-coding the
same operation.
Update the comments accordingly.
Fixes: bcf8b616deb87941 ("drm/format-helper: Add drm_fb_xrgb8888_to_mono_reversed()")
Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
Acked-by: Javier Martinez Canillas <javierm@redhat.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20220317081830.1211400-3-geert@linux-m68k.org
2022-03-17 16:18:27 +08:00
|
|
|
byte |= BIT(i);
|
2022-02-14 21:37:06 +08:00
|
|
|
}
|
2022-04-27 22:14:08 +08:00
|
|
|
*dbuf8++ = byte;
|
2022-02-14 21:37:06 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2022-03-17 16:18:26 +08:00
|
|
|
* drm_fb_xrgb8888_to_mono - Convert XRGB8888 to monochrome
|
2022-08-08 20:54:04 +08:00
|
|
|
* @dst: Array of monochrome destination buffers (0=black, 1=white)
|
|
|
|
* @dst_pitch: Array of numbers of bytes between the start of two consecutive scanlines
|
|
|
|
* within @dst; can be NULL if scanlines are stored next to each other.
|
2022-08-08 20:54:06 +08:00
|
|
|
* @src: Array of XRGB8888 source buffers
|
2022-02-14 21:37:06 +08:00
|
|
|
* @fb: DRM framebuffer
|
|
|
|
* @clip: Clip rectangle area to copy
|
|
|
|
*
|
2022-08-08 20:54:04 +08:00
|
|
|
* This function copies parts of a framebuffer to display memory and converts the
|
|
|
|
* color format during the process. Destination and framebuffer formats must match. The
|
2022-08-08 20:54:06 +08:00
|
|
|
* parameters @dst, @dst_pitch and @src refer to arrays. Each array must have at
|
2022-08-08 20:54:04 +08:00
|
|
|
* least as many entries as there are planes in @fb's format. Each entry stores the
|
|
|
|
* value for the format's respective color plane at the same index.
|
|
|
|
*
|
|
|
|
* This function does not apply clipping on @dst (i.e. the destination is at the
|
|
|
|
* top-left corner). The first pixel (upper left corner of the clip rectangle) will
|
|
|
|
* be converted and copied to the first bit (LSB) in the first byte of the monochrome
|
|
|
|
* destination buffer. If the caller requires that the first pixel in a byte must
|
|
|
|
* be located at an x-coordinate that is a multiple of 8, then the caller must take
|
|
|
|
* care itself of supplying a suitable clip rectangle.
|
|
|
|
*
|
|
|
|
* DRM doesn't have native monochrome support. Drivers can use this function for
|
|
|
|
* monochrome devices that don't support XRGB8888 natively. Such drivers can
|
|
|
|
* announce the commonly supported XR24 format to userspace and use this function
|
|
|
|
* to convert to the native format.
|
2022-02-14 21:37:06 +08:00
|
|
|
*
|
|
|
|
* This function uses drm_fb_xrgb8888_to_gray8() to convert to grayscale and
|
2022-03-17 16:18:26 +08:00
|
|
|
* then the result is converted from grayscale to monochrome.
|
2022-02-14 21:37:06 +08:00
|
|
|
*/
|
2022-08-08 20:54:04 +08:00
|
|
|
void drm_fb_xrgb8888_to_mono(struct iosys_map *dst, const unsigned int *dst_pitch,
|
2022-08-08 20:54:06 +08:00
|
|
|
const struct iosys_map *src, const struct drm_framebuffer *fb,
|
2022-08-08 20:54:04 +08:00
|
|
|
const struct drm_rect *clip)
|
2022-02-14 21:37:06 +08:00
|
|
|
{
|
2022-08-08 20:54:04 +08:00
|
|
|
static const unsigned int default_dst_pitch[DRM_FORMAT_MAX_PLANES] = {
|
|
|
|
0, 0, 0, 0
|
|
|
|
};
|
2022-02-14 21:37:06 +08:00
|
|
|
unsigned int linepixels = drm_rect_width(clip);
|
drm/format-helper: Fix XRGB888 to monochrome conversion
The conversion functions drm_fb_xrgb8888_to_mono() and
drm_fb_gray8_to_mono_line() do not behave correctly when the
horizontal boundaries of the clip rectangle are not multiples of 8:
a. When x1 % 8 != 0, the calculated pitch is not correct,
b. When x2 % 8 != 0, the pixel data for the last byte is wrong.
Simplify the code and fix (a) by:
1. Removing start_offset, and always storing the first pixel in the
first bit of the monochrome destination buffer.
Drivers that require the first pixel in a byte to be located at an
x-coordinate that is a multiple of 8 can always align the clip
rectangle before calling drm_fb_xrgb8888_to_mono().
Note that:
- The ssd130x driver does not need the alignment, as the
monochrome buffer is a temporary format,
- The repaper driver always updates the full screen, so the clip
rectangle is always aligned.
2. Passing the number of pixels to drm_fb_gray8_to_mono_line(),
instead of the number of bytes, and the number of pixels in the
last byte.
Fix (b) by explicitly setting the target bit, instead of always setting
bit 7 and shifting the value in each loop iteration.
Remove the bogus pitch check, which operates on bytes instead of pixels,
and triggers when e.g. flashing the cursor on a text console with a font
that is 8 pixels wide.
Drop the confusing comment about scanlines, as a pitch in bytes always
contains a multiple of 8 pixels.
While at it, use the drm_rect_height() helper instead of open-coding the
same operation.
Update the comments accordingly.
Fixes: bcf8b616deb87941 ("drm/format-helper: Add drm_fb_xrgb8888_to_mono_reversed()")
Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
Acked-by: Javier Martinez Canillas <javierm@redhat.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20220317081830.1211400-3-geert@linux-m68k.org
2022-03-17 16:18:27 +08:00
|
|
|
unsigned int lines = drm_rect_height(clip);
|
2022-02-14 21:37:06 +08:00
|
|
|
unsigned int cpp = fb->format->cpp[0];
|
|
|
|
unsigned int len_src32 = linepixels * cpp;
|
|
|
|
struct drm_device *dev = fb->dev;
|
2022-08-08 20:54:06 +08:00
|
|
|
void *vaddr = src[0].vaddr;
|
2022-08-08 20:54:04 +08:00
|
|
|
unsigned int dst_pitch_0;
|
2022-02-14 21:37:06 +08:00
|
|
|
unsigned int y;
|
2022-08-08 20:54:04 +08:00
|
|
|
u8 *mono = dst[0].vaddr, *gray8;
|
2022-02-14 21:37:06 +08:00
|
|
|
u32 *src32;
|
|
|
|
|
|
|
|
if (drm_WARN_ON(dev, fb->format->format != DRM_FORMAT_XRGB8888))
|
|
|
|
return;
|
|
|
|
|
2022-08-08 20:54:04 +08:00
|
|
|
if (!dst_pitch)
|
|
|
|
dst_pitch = default_dst_pitch;
|
|
|
|
dst_pitch_0 = dst_pitch[0];
|
|
|
|
|
2022-02-14 21:37:06 +08:00
|
|
|
/*
|
drm/format-helper: Fix XRGB888 to monochrome conversion
The conversion functions drm_fb_xrgb8888_to_mono() and
drm_fb_gray8_to_mono_line() do not behave correctly when the
horizontal boundaries of the clip rectangle are not multiples of 8:
a. When x1 % 8 != 0, the calculated pitch is not correct,
b. When x2 % 8 != 0, the pixel data for the last byte is wrong.
Simplify the code and fix (a) by:
1. Removing start_offset, and always storing the first pixel in the
first bit of the monochrome destination buffer.
Drivers that require the first pixel in a byte to be located at an
x-coordinate that is a multiple of 8 can always align the clip
rectangle before calling drm_fb_xrgb8888_to_mono().
Note that:
- The ssd130x driver does not need the alignment, as the
monochrome buffer is a temporary format,
- The repaper driver always updates the full screen, so the clip
rectangle is always aligned.
2. Passing the number of pixels to drm_fb_gray8_to_mono_line(),
instead of the number of bytes, and the number of pixels in the
last byte.
Fix (b) by explicitly setting the target bit, instead of always setting
bit 7 and shifting the value in each loop iteration.
Remove the bogus pitch check, which operates on bytes instead of pixels,
and triggers when e.g. flashing the cursor on a text console with a font
that is 8 pixels wide.
Drop the confusing comment about scanlines, as a pitch in bytes always
contains a multiple of 8 pixels.
While at it, use the drm_rect_height() helper instead of open-coding the
same operation.
Update the comments accordingly.
Fixes: bcf8b616deb87941 ("drm/format-helper: Add drm_fb_xrgb8888_to_mono_reversed()")
Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
Acked-by: Javier Martinez Canillas <javierm@redhat.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20220317081830.1211400-3-geert@linux-m68k.org
2022-03-17 16:18:27 +08:00
|
|
|
* The mono destination buffer contains 1 bit per pixel
|
2022-02-14 21:37:06 +08:00
|
|
|
*/
|
2022-08-08 20:54:04 +08:00
|
|
|
if (!dst_pitch_0)
|
|
|
|
dst_pitch_0 = DIV_ROUND_UP(linepixels, 8);
|
2022-02-14 21:37:06 +08:00
|
|
|
|
|
|
|
/*
|
2022-08-02 08:04:02 +08:00
|
|
|
* The dma memory is write-combined so reads are uncached.
|
2022-02-14 21:37:06 +08:00
|
|
|
* Speed up by fetching one line at a time.
|
|
|
|
*
|
2022-03-17 16:18:26 +08:00
|
|
|
* Also, format conversion from XR24 to monochrome are done
|
|
|
|
* line-by-line but are converted to 8-bit grayscale as an
|
|
|
|
* intermediate step.
|
2022-02-14 21:37:06 +08:00
|
|
|
*
|
|
|
|
* Allocate a buffer to be used for both copying from the cma
|
|
|
|
* memory and to store the intermediate grayscale line pixels.
|
|
|
|
*/
|
|
|
|
src32 = kmalloc(len_src32 + linepixels, GFP_KERNEL);
|
|
|
|
if (!src32)
|
|
|
|
return;
|
|
|
|
|
|
|
|
gray8 = (u8 *)src32 + len_src32;
|
|
|
|
|
|
|
|
vaddr += clip_offset(clip, fb->pitches[0], cpp);
|
|
|
|
for (y = 0; y < lines; y++) {
|
|
|
|
src32 = memcpy(src32, vaddr, len_src32);
|
|
|
|
drm_fb_xrgb8888_to_gray8_line(gray8, src32, linepixels);
|
drm/format-helper: Fix XRGB888 to monochrome conversion
The conversion functions drm_fb_xrgb8888_to_mono() and
drm_fb_gray8_to_mono_line() do not behave correctly when the
horizontal boundaries of the clip rectangle are not multiples of 8:
a. When x1 % 8 != 0, the calculated pitch is not correct,
b. When x2 % 8 != 0, the pixel data for the last byte is wrong.
Simplify the code and fix (a) by:
1. Removing start_offset, and always storing the first pixel in the
first bit of the monochrome destination buffer.
Drivers that require the first pixel in a byte to be located at an
x-coordinate that is a multiple of 8 can always align the clip
rectangle before calling drm_fb_xrgb8888_to_mono().
Note that:
- The ssd130x driver does not need the alignment, as the
monochrome buffer is a temporary format,
- The repaper driver always updates the full screen, so the clip
rectangle is always aligned.
2. Passing the number of pixels to drm_fb_gray8_to_mono_line(),
instead of the number of bytes, and the number of pixels in the
last byte.
Fix (b) by explicitly setting the target bit, instead of always setting
bit 7 and shifting the value in each loop iteration.
Remove the bogus pitch check, which operates on bytes instead of pixels,
and triggers when e.g. flashing the cursor on a text console with a font
that is 8 pixels wide.
Drop the confusing comment about scanlines, as a pitch in bytes always
contains a multiple of 8 pixels.
While at it, use the drm_rect_height() helper instead of open-coding the
same operation.
Update the comments accordingly.
Fixes: bcf8b616deb87941 ("drm/format-helper: Add drm_fb_xrgb8888_to_mono_reversed()")
Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
Acked-by: Javier Martinez Canillas <javierm@redhat.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20220317081830.1211400-3-geert@linux-m68k.org
2022-03-17 16:18:27 +08:00
|
|
|
drm_fb_gray8_to_mono_line(mono, gray8, linepixels);
|
2022-02-14 21:37:06 +08:00
|
|
|
vaddr += fb->pitches[0];
|
2022-08-08 20:54:04 +08:00
|
|
|
mono += dst_pitch_0;
|
2022-02-14 21:37:06 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
kfree(src32);
|
|
|
|
}
|
2022-03-17 16:18:26 +08:00
|
|
|
EXPORT_SYMBOL(drm_fb_xrgb8888_to_mono);
|
2022-09-05 22:16:48 +08:00
|
|
|
|
2023-01-02 19:29:26 +08:00
|
|
|
static uint32_t drm_fb_nonalpha_fourcc(uint32_t fourcc)
|
|
|
|
{
|
|
|
|
/* only handle formats with depth != 0 and alpha channel */
|
|
|
|
switch (fourcc) {
|
|
|
|
case DRM_FORMAT_ARGB1555:
|
|
|
|
return DRM_FORMAT_XRGB1555;
|
|
|
|
case DRM_FORMAT_ABGR1555:
|
|
|
|
return DRM_FORMAT_XBGR1555;
|
|
|
|
case DRM_FORMAT_RGBA5551:
|
|
|
|
return DRM_FORMAT_RGBX5551;
|
|
|
|
case DRM_FORMAT_BGRA5551:
|
|
|
|
return DRM_FORMAT_BGRX5551;
|
|
|
|
case DRM_FORMAT_ARGB8888:
|
|
|
|
return DRM_FORMAT_XRGB8888;
|
|
|
|
case DRM_FORMAT_ABGR8888:
|
|
|
|
return DRM_FORMAT_XBGR8888;
|
|
|
|
case DRM_FORMAT_RGBA8888:
|
|
|
|
return DRM_FORMAT_RGBX8888;
|
|
|
|
case DRM_FORMAT_BGRA8888:
|
|
|
|
return DRM_FORMAT_BGRX8888;
|
|
|
|
case DRM_FORMAT_ARGB2101010:
|
|
|
|
return DRM_FORMAT_XRGB2101010;
|
|
|
|
case DRM_FORMAT_ABGR2101010:
|
|
|
|
return DRM_FORMAT_XBGR2101010;
|
|
|
|
case DRM_FORMAT_RGBA1010102:
|
|
|
|
return DRM_FORMAT_RGBX1010102;
|
|
|
|
case DRM_FORMAT_BGRA1010102:
|
|
|
|
return DRM_FORMAT_BGRX1010102;
|
|
|
|
}
|
|
|
|
|
|
|
|
return fourcc;
|
|
|
|
}
|
|
|
|
|
2022-09-05 22:16:48 +08:00
|
|
|
static bool is_listed_fourcc(const uint32_t *fourccs, size_t nfourccs, uint32_t fourcc)
|
|
|
|
{
|
|
|
|
const uint32_t *fourccs_end = fourccs + nfourccs;
|
|
|
|
|
|
|
|
while (fourccs < fourccs_end) {
|
|
|
|
if (*fourccs == fourcc)
|
|
|
|
return true;
|
|
|
|
++fourccs;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* drm_fb_build_fourcc_list - Filters a list of supported color formats against
|
|
|
|
* the device's native formats
|
|
|
|
* @dev: DRM device
|
|
|
|
* @native_fourccs: 4CC codes of natively supported color formats
|
|
|
|
* @native_nfourccs: The number of entries in @native_fourccs
|
|
|
|
* @fourccs_out: Returns 4CC codes of supported color formats
|
|
|
|
* @nfourccs_out: The number of available entries in @fourccs_out
|
|
|
|
*
|
|
|
|
* This function create a list of supported color format from natively
|
2023-01-02 19:29:26 +08:00
|
|
|
* supported formats and additional emulated formats.
|
2022-09-05 22:16:48 +08:00
|
|
|
* At a minimum, most userspace programs expect at least support for
|
|
|
|
* XRGB8888 on the primary plane. Devices that have to emulate the
|
|
|
|
* format, and possibly others, can use drm_fb_build_fourcc_list() to
|
|
|
|
* create a list of supported color formats. The returned list can
|
|
|
|
* be handed over to drm_universal_plane_init() et al. Native formats
|
2023-01-02 19:29:26 +08:00
|
|
|
* will go before emulated formats. Native formats with alpha channel
|
|
|
|
* will be replaced by such without, as primary planes usually don't
|
|
|
|
* support alpha. Other heuristics might be applied
|
2022-09-05 22:16:48 +08:00
|
|
|
* to optimize the order. Formats near the beginning of the list are
|
2023-01-02 19:29:26 +08:00
|
|
|
* usually preferred over formats near the end of the list.
|
2022-09-05 22:16:48 +08:00
|
|
|
*
|
|
|
|
* Returns:
|
|
|
|
* The number of color-formats 4CC codes returned in @fourccs_out.
|
|
|
|
*/
|
|
|
|
size_t drm_fb_build_fourcc_list(struct drm_device *dev,
|
|
|
|
const u32 *native_fourccs, size_t native_nfourccs,
|
|
|
|
u32 *fourccs_out, size_t nfourccs_out)
|
|
|
|
{
|
2023-01-02 19:29:26 +08:00
|
|
|
/*
|
|
|
|
* XRGB8888 is the default fallback format for most of userspace
|
|
|
|
* and it's currently the only format that should be emulated for
|
|
|
|
* the primary plane. Only if there's ever another default fallback,
|
|
|
|
* it should be added here.
|
|
|
|
*/
|
|
|
|
static const uint32_t extra_fourccs[] = {
|
|
|
|
DRM_FORMAT_XRGB8888,
|
|
|
|
};
|
|
|
|
static const size_t extra_nfourccs = ARRAY_SIZE(extra_fourccs);
|
|
|
|
|
2022-09-05 22:16:48 +08:00
|
|
|
u32 *fourccs = fourccs_out;
|
|
|
|
const u32 *fourccs_end = fourccs_out + nfourccs_out;
|
|
|
|
size_t i;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* The device's native formats go first.
|
|
|
|
*/
|
|
|
|
|
|
|
|
for (i = 0; i < native_nfourccs; ++i) {
|
2023-01-02 19:29:26 +08:00
|
|
|
/*
|
|
|
|
* Several DTs, boot loaders and firmware report native
|
|
|
|
* alpha formats that are non-alpha formats instead. So
|
|
|
|
* replace alpha formats by non-alpha formats.
|
|
|
|
*/
|
|
|
|
u32 fourcc = drm_fb_nonalpha_fourcc(native_fourccs[i]);
|
2022-09-05 22:16:48 +08:00
|
|
|
|
|
|
|
if (is_listed_fourcc(fourccs_out, fourccs - fourccs_out, fourcc)) {
|
|
|
|
continue; /* skip duplicate entries */
|
|
|
|
} else if (fourccs == fourccs_end) {
|
|
|
|
drm_warn(dev, "Ignoring native format %p4cc\n", &fourcc);
|
|
|
|
continue; /* end of available output buffer */
|
|
|
|
}
|
|
|
|
|
|
|
|
drm_dbg_kms(dev, "adding native format %p4cc\n", &fourcc);
|
|
|
|
|
|
|
|
*fourccs = fourcc;
|
|
|
|
++fourccs;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* The extra formats, emulated by the driver, go second.
|
|
|
|
*/
|
|
|
|
|
2023-01-02 19:29:26 +08:00
|
|
|
for (i = 0; (i < extra_nfourccs) && (fourccs < fourccs_end); ++i) {
|
|
|
|
u32 fourcc = extra_fourccs[i];
|
2022-09-05 22:16:48 +08:00
|
|
|
|
|
|
|
if (is_listed_fourcc(fourccs_out, fourccs - fourccs_out, fourcc)) {
|
|
|
|
continue; /* skip duplicate and native entries */
|
|
|
|
} else if (fourccs == fourccs_end) {
|
|
|
|
drm_warn(dev, "Ignoring emulated format %p4cc\n", &fourcc);
|
|
|
|
continue; /* end of available output buffer */
|
|
|
|
}
|
|
|
|
|
|
|
|
drm_dbg_kms(dev, "adding emulated format %p4cc\n", &fourcc);
|
|
|
|
|
|
|
|
*fourccs = fourcc;
|
|
|
|
++fourccs;
|
|
|
|
}
|
|
|
|
|
|
|
|
return fourccs - fourccs_out;
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL(drm_fb_build_fourcc_list);
|