硬汉嵌入式论坛

 找回密码
 立即注册
查看: 3066|回复: 11
收起左侧

[DMA2D] STM32H7的DAM2D实现YCbCr转RGB的API

[复制链接]

1万

主题

6万

回帖

10万

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
106660
QQ
发表于 2019-4-22 03:05:09 | 显示全部楼层 |阅读模式
还是这种的API调用起来省事

  1. /**
  2.   * @brief  DMA2D conversion from YCbCr (video output) to RGB (Display frame buffer)
  3.   * @param  pSrc : Source buffer pointer
  4.   * @param  xsize: Horizontal size of the frame buffer
  5.   * @param  ysize: Vertical size of the frame buffer
  6.   * @retval None
  7.   */
  8. void DMA2D_CopyBuffer_YCbCr_To_RGB(uint32_t *pSrc, uint16_t xsize, uint16_t ysize)
  9. {
  10.   uint32_t inputLineOffset = 0;
  11.   uint32_t destination;
  12.   U32 BufferSize;
  13.   U32 regValue, regMask;
  14.   
  15.   /* Wait if there is a transfer in progress */
  16.   _DMA2D_ExecOperation();
  17.   
  18.   /* Take the TransferInProgress flag */
  19.   TransferInProgress = 1;

  20.   /* Get the buffer size */
  21.   BufferSize = _GetBufferSize(0);
  22.   
  23.   /* Calculate all the needed DMA2D inputs */
  24.   destination = _aAddr[0] + BufferSize * _aBufferIndex[0];   
  25.   
  26.   inputLineOffset = xsize % 16;
  27.   if(inputLineOffset != 0)
  28.   {
  29.     inputLineOffset = 16 - inputLineOffset;
  30.   }
  31.   
  32.   regValue = DMA2D_INPUT_YCBCR | (DMA2D_REPLACE_ALPHA << 16) | \
  33.                         (DMA2D_REGULAR_ALPHA << 20)| \
  34.             (DMA2D_RB_REGULAR << 21)   | \
  35.             (0xFFU << 24)               | \
  36.             (DMA2D_CSS_420 << 18);
  37.                        
  38.   regMask  = DMA2D_BGPFCCR_CM | DMA2D_BGPFCCR_AM | DMA2D_BGPFCCR_ALPHA | DMA2D_BGPFCCR_AI | DMA2D_BGPFCCR_RBS | DMA2D_FGPFCCR_CSS;
  39.   
  40.   /* Setup DMA2D Configuration */   
  41.   DMA2D->CR      = 0x00010000UL | (1 << 9);
  42.   DMA2D->OPFCCR  = DMA2D_OUTPUT_RGB565;
  43.   DMA2D->OOR     = 640 - xsize;
  44.   DMA2D->OPFCCR  |= (DMA2D_REGULAR_ALPHA << 20);
  45.   DMA2D->OPFCCR  |= (DMA2D_RB_REGULAR << 21);   
  46.   DMA2D->FGPFCCR |= (regMask & regValue);      
  47.   DMA2D->FGOR    = inputLineOffset;
  48.   DMA2D->NLR     = (U32)(xsize << 16) | (U16)ysize;      
  49.   DMA2D->OMAR    = (U32)destination;
  50.   DMA2D->FGMAR   = (U32)pSrc;  
  51.   
  52.   /* Start the transfer, and enable the transfer complete IT */  
  53.   DMA2D->CR     |= (1|DMA2D_IT_TC);
  54.   
  55.   /* Wait for the end of the transfer */
  56.   _DMA2D_ExecOperation();
  57.    
  58. }
复制代码


回复

使用道具 举报

0

主题

5

回帖

5

积分

新手上路

积分
5
发表于 2020-4-2 21:21:18 | 显示全部楼层
Hello,

I have question. is this function work with the output from the DCMI camera interface which is progressive scan or only with the output of the hardware JPEG decoder?

Best Regards
Mahmoud
回复

使用道具 举报

1万

主题

6万

回帖

10万

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
106660
QQ
 楼主| 发表于 2020-4-3 09:05:37 | 显示全部楼层
msa1988 发表于 2020-4-2 21:21
Hello,

I have question. is this function work with the output from the DCMI camera interface whic ...

STM32H7 hardware JPEG peripherals do not  support  progressive jpeg picture。
回复

使用道具 举报

0

主题

5

回帖

5

积分

新手上路

积分
5
发表于 2020-4-3 16:12:40 | 显示全部楼层
eric2013 发表于 2020-4-3 09:05
STM32H7 hardware JPEG peripherals do not  support  progressive jpeg picture。

Hello,

So what is the video output used in your function
Progressive Scan YCBCR or 8x8 block YCBCR?

Best Regards
Mahmoud Salem
回复

使用道具 举报

1万

主题

6万

回帖

10万

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
106660
QQ
 楼主| 发表于 2020-4-3 16:29:28 | 显示全部楼层
msa1988 发表于 2020-4-3 16:12
Hello,

So what is the video output used in your function

I just use baseline jpeg pic with hardware JPEG peripherals
回复

使用道具 举报

0

主题

5

回帖

5

积分

新手上路

积分
5
发表于 2020-4-3 17:05:37 | 显示全部楼层
eric2013 发表于 2020-4-3 16:29
I just use baseline jpeg pic with hardware JPEG peripherals

Thank you for the information.

Do you think that the DMA2D can convert the YCBCR output from the DCMI to RGB565 to display?

回复

使用道具 举报

1万

主题

6万

回帖

10万

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
106660
QQ
 楼主| 发表于 2020-4-3 18:36:11 | 显示全部楼层
msa1988 发表于 2020-4-3 17:05
Thank you for the information.

Do you think that the DMA2D can convert the YCBCR output from th ...

Yes, dma2d can convert
回复

使用道具 举报

0

主题

5

回帖

5

积分

新手上路

积分
5
发表于 2020-4-3 18:46:27 | 显示全部楼层
eric2013 发表于 2020-4-3 18:36
Yes, dma2d can convert

Can i use your API function to do this conversion?

Regards
Mahmoud
回复

使用道具 举报

1万

主题

6万

回帖

10万

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
106660
QQ
 楼主| 发表于 2020-4-3 18:50:06 | 显示全部楼层
msa1988 发表于 2020-4-3 18:46
Can i use your API function to do this conversion?

Regards

I port it to emWin jpeg low level interface。 other application,I have no。

http://www.armbbs.cn/forum.php?mod=viewthread&tid=93843


回复

使用道具 举报

0

主题

5

回帖

5

积分

新手上路

积分
5
发表于 2020-4-3 19:01:06 | 显示全部楼层
Thank you

回复

使用道具 举报

0

主题

1

回帖

1

积分

新手上路

积分
1
发表于 2023-10-20 14:18:12 | 显示全部楼层
请问该api 在哪块开发板有例程
回复

使用道具 举报

1万

主题

6万

回帖

10万

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
106660
QQ
 楼主| 发表于 2023-10-21 10:50:23 | 显示全部楼层
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|小黑屋|Archiver|手机版|硬汉嵌入式论坛

GMT+8, 2024-4-28 22:45 , Processed in 0.254950 second(s), 25 queries .

Powered by Discuz! X3.4 Licensed

Copyright © 2001-2023, Tencent Cloud.

快速回复 返回顶部 返回列表