Commit 67b2243d8e728164d3c6badef9394c0a6990651a
1 parent
41d277b5c1
Exists in
smarc_8mq-imx_v2020.04_5.4.24_2.1.0
and in
1 other branch
MLK-23964-4 video: bmp: Support 8bits BMP to 32 bits display
Update video bmp codes to support 8 bits BMP to 32 bits conversion so that we can display 8 bits logo on 32 bits display Signed-off-by: Ye Li <ye.li@nxp.com> (cherry picked from commit e3aa9194b7ee98841b5432dd8189caacfd56068e)
Showing 1 changed file with 26 additions and 4 deletions Side-by-side Diff
drivers/video/video_bmp.c
... | ... | @@ -232,6 +232,8 @@ |
232 | 232 | */ |
233 | 233 | if (bpix != bmp_bpix && |
234 | 234 | !(bmp_bpix == 8 && bpix == 16) && |
235 | + !(bmp_bpix == 8 && bpix == 24) && | |
236 | + !(bmp_bpix == 8 && bpix == 32) && | |
235 | 237 | !(bmp_bpix == 24 && bpix == 16) && |
236 | 238 | !(bmp_bpix == 24 && bpix == 32)) { |
237 | 239 | printf("Error: %d bit/pixel mode, but BMP has %d bit/pixel\n", |
... | ... | @@ -264,6 +266,7 @@ |
264 | 266 | switch (bmp_bpix) { |
265 | 267 | case 1: |
266 | 268 | case 8: { |
269 | + struct bmp_color_table_entry *cte; | |
267 | 270 | cmap_base = priv->cmap; |
268 | 271 | #ifdef CONFIG_VIDEO_BMP_RLE8 |
269 | 272 | u32 compression = get_unaligned_le32(&bmp->header.compression); |
270 | 273 | |
271 | 274 | |
272 | 275 | |
273 | 276 | |
274 | 277 | |
... | ... | @@ -280,20 +283,39 @@ |
280 | 283 | } |
281 | 284 | #endif |
282 | 285 | |
283 | - if (bpix != 16) | |
286 | + if (bpix == 8) | |
284 | 287 | byte_width = width; |
285 | - else | |
288 | + else if (bpix == 16) | |
286 | 289 | byte_width = width * 2; |
290 | + else if (bpix == 24) | |
291 | + byte_width = width * 3; | |
292 | + else /* 32 */ | |
293 | + byte_width = width * 4; | |
287 | 294 | |
288 | 295 | for (i = 0; i < height; ++i) { |
289 | 296 | WATCHDOG_RESET(); |
290 | 297 | for (j = 0; j < width; j++) { |
291 | - if (bpix != 16) { | |
298 | + if (bpix == 8) { | |
292 | 299 | fb_put_byte(&fb, &bmap); |
293 | - } else { | |
300 | + } else if (bpix == 16) { | |
294 | 301 | *(uint16_t *)fb = cmap_base[*bmap]; |
295 | 302 | bmap++; |
296 | 303 | fb += sizeof(uint16_t) / sizeof(*fb); |
304 | + } else if (bpix == 24) { | |
305 | + /* Only support big endian */ | |
306 | + cte = &palette[*bmap]; | |
307 | + bmap++; | |
308 | + *(fb++) = cte->red; | |
309 | + *(fb++) = cte->green; | |
310 | + *(fb++) = cte->blue; | |
311 | + } else if (bpix == 32) { | |
312 | + /* Only support big endian */ | |
313 | + cte = &palette[*bmap]; | |
314 | + bmap++; | |
315 | + *(fb++) = cte->blue; | |
316 | + *(fb++) = cte->green; | |
317 | + *(fb++) = cte->red; | |
318 | + *(fb++) = 0; | |
297 | 319 | } |
298 | 320 | } |
299 | 321 | bmap += (padded_width - width); |