【SMART】【BSP】【allwinner】Fix smart serial_v2 bypass compile error issue (#10524)

* Modify the reference path of the header file in the middle section

* format

* Fix smart serial_v2 bypass compile error issue

* add allwinner/d1s ci
This commit is contained in:
rcitach
2025-08-01 20:59:08 +08:00
committed by GitHub
parent d82dd71aef
commit ae50e406da
7 changed files with 573 additions and 490 deletions

View File

@@ -490,6 +490,13 @@
"SUB_RTT_BSP": [
"xuantie/virt64/c906"
]
},
{
"RTT_BSP": "allwinner-smart",
"RTT_TOOL_CHAIN": "sourcery-riscv64-general-toolchain",
"SUB_RTT_BSP": [
"allwinner/d1s"
]
}
]
}

View File

@@ -163,6 +163,14 @@ jobs:
/opt/riscv64-unknown-elf-toolchain-10.2.0-2020.12.8-x86_64-linux-ubuntu14/bin/riscv64-unknown-elf-gcc --version
echo "RTT_EXEC_PATH=/opt/riscv64-unknown-elf-toolchain-10.2.0-2020.12.8-x86_64-linux-ubuntu14/bin" >> $GITHUB_ENV
- name: Install Riscv64 rt-thread smart general toolchain
if: ${{ matrix.legs.RTT_TOOL_CHAIN == 'sourcery-riscv64-general-toolchain' && success() }}
run: |
wget -q https://github.com/RT-Thread/rt-thread/releases/download/v5.2.0/riscv64gc-linux-musleabi_for_x86_64-pc-linux-gnu_252938-345d8b6e45.tar.bz2
sudo tar xjf riscv64gc-linux-musleabi_for_x86_64-pc-linux-gnu_252938-345d8b6e45.tar.bz2 -C /opt
/opt/riscv64gc-linux-musleabi_for_x86_64-pc-linux-gnu/bin/riscv64-unknown-linux-musl-gcc --version
echo "RTT_EXEC_PATH=/opt/riscv64gc-linux-musleabi_for_x86_64-pc-linux-gnu/bin" >> $GITHUB_ENV
- name: Install Xuantie-900-gcc-elf-newlib Tools
if: ${{ matrix.legs.RTT_TOOL_CHAIN == 'sourcery-Xuantie-900-gcc-elf-newlib' && success() }}
run: |

View File

@@ -19,12 +19,12 @@
#include <hal_cache.h>
#include <stdlib.h>
#include <string.h>
#include <interrupt.h>
#include <hal_interrupt.h>
#include <init.h>
#include <hal_clk.h>
#include <hal_reset.h>
#include <hal_timer.h>
// #include <melis/standby/standby.h>
/* #include <melis/standby/standby.h> */
#include "g2d_driver_i.h"
#include "g2d_top.h"
@@ -81,9 +81,11 @@ void *g2d_malloc(__u32 bytes_num, __u32 *phy_addr)
char* vir_addr;
if (bytes_num != 0) {
if (bytes_num != 0)
{
vir_addr = hal_malloc_align(bytes_num, CACHELINE_LEN);
if(vir_addr!=NULL){
if(vir_addr!=NULL)
{
*phy_addr = __va_to_pa((unsigned long)vir_addr);
memset((void *)vir_addr, 0, bytes_num);
hal_dcache_clean((unsigned long)vir_addr, bytes_num);
@@ -132,38 +134,45 @@ __s32 g2d_byte_cal(__u32 format, __u32 *ycnt, __u32 *ucnt, __u32 *vcnt)
else if (format <= G2D_FORMAT_BGRA1010102)
*ycnt = 4;
else if (format <= 0x23) {
else if (format <= 0x23)
{
*ycnt = 2;
}
else if (format <= 0x25) {
else if (format <= 0x25)
{
*ycnt = 1;
*ucnt = 2;
}
else if (format == 0x26) {
else if (format == 0x26)
{
*ycnt = 1;
*ucnt = 1;
*vcnt = 1;
}
else if (format <= 0x29) {
else if (format <= 0x29)
{
*ycnt = 1;
*ucnt = 2;
}
else if (format == 0x2a) {
else if (format == 0x2a)
{
*ycnt = 1;
*ucnt = 1;
*vcnt = 1;
}
else if (format <= 0x2d) {
else if (format <= 0x2d)
{
*ycnt = 1;
*ucnt = 2;
}
else if (format == 0x2e) {
else if (format == 0x2e)
{
*ycnt = 1;
*ucnt = 1;
*vcnt = 1;
@@ -172,7 +181,8 @@ __s32 g2d_byte_cal(__u32 format, __u32 *ycnt, __u32 *ucnt, __u32 *vcnt)
else if (format == 0x30)
*ycnt = 1;
else if (format <= 0x36) {
else if (format <= 0x36)
{
*ycnt = 2;
*ucnt = 4;
}
@@ -187,7 +197,8 @@ __s32 g2d_byte_cal(__u32 format, __u32 *ycnt, __u32 *ucnt, __u32 *vcnt)
*/
__u32 cal_align(__u32 width, __u32 align)
{
switch (align) {
switch (align)
{
case 0:
return width;
case 4:
@@ -212,7 +223,8 @@ __s32 g2d_image_check(g2d_image_enh *p_image)
{
__s32 ret = -EINVAL;
if (!p_image) {
if (!p_image)
{
G2D_ERR_MSG("NUll pointer!\n");
goto OUT;
}
@@ -224,35 +236,40 @@ __s32 g2d_image_check(g2d_image_enh *p_image)
((p_image->clip_rect.x > 0) &&
(p_image->clip_rect.x > p_image->width - 1)) ||
((p_image->clip_rect.y > 0) &&
(p_image->clip_rect.y > p_image->height - 1))) {
(p_image->clip_rect.y > p_image->height - 1)))
{
G2D_ERR_MSG("Invalid imager parameter setting\n");
goto OUT;
}
if (((p_image->clip_rect.x < 0) &&
((-p_image->clip_rect.x) <
p_image->clip_rect.w))) {
p_image->clip_rect.w)))
{
p_image->clip_rect.w =
p_image->clip_rect.w +
p_image->clip_rect.x;
p_image->clip_rect.x = 0;
} else if ((p_image->clip_rect.x +
p_image->clip_rect.w)
> p_image->width) {
> p_image->width)
{
p_image->clip_rect.w =
p_image->width -
p_image->clip_rect.x;
}
if (((p_image->clip_rect.y < 0) &&
((-p_image->clip_rect.y) <
p_image->clip_rect.h))) {
p_image->clip_rect.h)))
{
p_image->clip_rect.h =
p_image->clip_rect.h +
p_image->clip_rect.y;
p_image->clip_rect.y = 0;
} else if ((p_image->clip_rect.y +
p_image->clip_rect.h)
> p_image->height) {
> p_image->height)
{
p_image->clip_rect.h =
p_image->height -
p_image->clip_rect.y;
@@ -292,7 +309,8 @@ static void reset_iommu(void)
*(volatile uint32_t *)(IOMMU_RESET_REG) = regval & (~(1 << G2D_IOMMU_MASTER_ID));
regval = (*(volatile uint32_t *)(IOMMU_RESET_REG));
if (!(regval & ((1 << G2D_IOMMU_MASTER_ID)))) {
if (!(regval & ((1 << G2D_IOMMU_MASTER_ID))))
{
*(volatile uint32_t *)(IOMMU_RESET_REG) = regval | ((1 << G2D_IOMMU_MASTER_ID));
}
regval = (*(volatile uint32_t *)(IOMMU_RESET_REG));
@@ -310,12 +328,13 @@ int g2d_wait_cmd_finish(unsigned int timeout)
{
int ret;
ret = hal_sem_timedwait(g2d_ext_hd.queue_sem,timeout* 10);
if (ret < 0) {
if (ret < 0)
{
reset_iommu();
g2d_bsp_reset();
G2D_ERR_MSG("G2D irq pending flag timeout\n");
g2d_ext_hd.finish_flag = 1;
//wake_up(&g2d_ext_hd.queue);
/* wake_up(&g2d_ext_hd.queue); */
return -1;
}
g2d_ext_hd.finish_flag = 0;
@@ -326,22 +345,25 @@ int g2d_wait_cmd_finish(unsigned int timeout)
irqreturn_t g2d_handle_irq(int irq, void *dev_id)
{
#if G2D_MIXER_RCQ_USED == 1
if (g2d_top_rcq_task_irq_query()) {
// g2d_top_mixer_reset();
if (g2d_top_rcq_task_irq_query())
{
/* g2d_top_mixer_reset(); */
g2d_ext_hd.finish_flag = 1;
hal_sem_post(g2d_ext_hd.queue_sem);
return IRQ_HANDLED;
}
#else
if (g2d_mixer_irq_query()) {
// g2d_top_mixer_reset();
if (g2d_mixer_irq_query())
{
/* g2d_top_mixer_reset(); */
g2d_ext_hd.finish_flag = 1;
hal_sem_post(g2d_ext_hd.queue_sem);
return IRQ_HANDLED;
}
#endif
if (g2d_rot_irq_query()) {
// g2d_top_rot_reset();
if (g2d_rot_irq_query())
{
/* g2d_top_rot_reset(); */
g2d_ext_hd.finish_flag = 1;
hal_sem_post(g2d_ext_hd.queue_sem);
return IRQ_HANDLED;
@@ -366,8 +388,10 @@ int g2d_clk_init(__g2d_info_t *info)
info->reset = hal_reset_control_get(reset_type, SUNXI_G2D_RESET_ID);
hal_reset_control_deassert(info->reset);
info->clk_parent= hal_clock_get(clk_type,SUNXI_G2D_CLK_PARENT);
for(i = 0; i < G2D_CLK_NUM; i++) {
if (clk_id[i] != (hal_clk_id_t)-1) {
for(i = 0; i < G2D_CLK_NUM; i++)
{
if (clk_id[i] != (hal_clk_id_t)-1)
{
info->clk[i] = hal_clock_get(clk_type, clk_id[i]);
}
}
@@ -380,7 +404,8 @@ int g2d_clk_init(__g2d_info_t *info)
int g2d_clk_exit(__g2d_info_t *info)
{
int i = 0;
for(i = 0; i < G2D_CLK_NUM; i++) {
for(i = 0; i < G2D_CLK_NUM; i++)
{
hal_clock_put(info->clk[i]);
}
@@ -394,26 +419,31 @@ int g2d_clock_enable(__g2d_info_t *info)
int ret = -1;
int i = 0;
ret = hal_reset_control_deassert(info->reset);
if (ret) {
if (ret)
{
G2D_ERR_MSG("deassert rst fail:%d\n", ret);
goto OUT;
}
ret = hal_clock_enable(info->clk_parent);
if (ret) {
if (ret)
{
G2D_ERR_MSG("Enable clk parent fail:%d\n", ret);
goto OUT;
}
ret = hal_clk_set_rate(info->clk[0], info->clk_rate);
if (ret) {
if (ret)
{
G2D_ERR_MSG("Set clk rate fail:%d:%u!\n", info->clk[0], (unsigned int)info->clk_rate);
goto OUT;
}
for(i = 0; i < G2D_CLK_NUM; i++) {
for(i = 0; i < G2D_CLK_NUM; i++)
{
ret = hal_clock_enable(info->clk[i]);
if (ret) {
if (ret)
{
G2D_ERR_MSG("Enable clk %d fail:%d\n", i, ret);
goto OUT;
}
@@ -427,22 +457,26 @@ static int g2d_clock_disable(__g2d_info_t *info)
{
int ret = -1;
int i;
for(i = 0; i < G2D_CLK_NUM; i++) {
for(i = 0; i < G2D_CLK_NUM; i++)
{
ret = hal_clock_disable(info->clk[i]);
if (ret) {
if (ret)
{
G2D_ERR_MSG("Disable clk %d fail:%d\n", i, ret);
goto OUT;
}
}
ret = hal_reset_control_assert(info->reset);
if (ret) {
if (ret)
{
G2D_ERR_MSG("assert rst fail:%d\n", ret);
goto OUT;
}
OUT:
return ret;
}
__s32 drv_g2d_init(__g2d_info_t *info)
{
int ret;
@@ -470,7 +504,8 @@ __s32 drv_g2d_init(__g2d_info_t *info)
int g2d_suspend(void)
{
g2d_mutex_lock(para.mutex);
if (para.opened) {
if (para.opened)
{
g2d_clock_disable(&para);
g2d_bsp_close();
}
@@ -486,7 +521,8 @@ int g2d_suspend(void)
int g2d_resume(void)
{
g2d_mutex_lock(para.mutex);
if (para.opened) {
if (para.opened)
{
g2d_clock_enable(&para);
g2d_bsp_open();
}
@@ -494,6 +530,7 @@ int g2d_resume(void)
return 0;
}
static void g2d_register_pm_dev_notify(void)
{
register_pm_dev_notify(g2d_suspend, g2d_resume, NULL);
@@ -524,7 +561,8 @@ int g2d_probe(void)
drv_g2d_init(info);
info->mutex = hal_sem_create(1);
global_lock = hal_sem_create(1);
if ((info->mutex == NULL) || (global_lock == NULL)) {
if ((info->mutex == NULL) || (global_lock == NULL))
{
G2D_ERR_MSG("sysfs_create_file fail!\n");
ret = -1;
}
@@ -563,7 +601,8 @@ int sunxi_g2d_open(void)
g2d_mutex_lock(para.mutex);
g2d_clock_enable(&para);
para.user_cnt++;
if (para.user_cnt == 1) {
if (para.user_cnt == 1)
{
para.opened = true;
g2d_bsp_open();
}
@@ -576,7 +615,8 @@ int sunxi_g2d_close(void)
{
g2d_mutex_lock(para.mutex);
para.user_cnt--;
if (para.user_cnt == 0) {
if (para.user_cnt == 0)
{
para.opened = false;
g2d_bsp_close();
}
@@ -590,6 +630,7 @@ int sunxi_g2d_close(void)
return 0;
}
int sunxi_g2d_control(int cmd, void *arg)
{
int ret = -1;
@@ -597,7 +638,8 @@ int sunxi_g2d_control(int cmd, void *arg)
g2d_ioctl_mutex_lock();
g2d_ext_hd.finish_flag = 0;
switch (cmd) {
switch (cmd)
{
case G2D_CMD_MIXER_TASK:
{
@@ -646,7 +688,8 @@ int sunxi_g2d_control(int cmd, void *arg)
struct g2d_mixer_task *p_task = NULL;
p_task = g2d_mixer_get_inst((int)karg[0]);
if(!p_task) {
if(!p_task)
{
ret = -EFAULT;
goto err_noput;
}
@@ -661,7 +704,8 @@ int sunxi_g2d_control(int cmd, void *arg)
memcpy(&blit_para, arg, sizeof(g2d_blt_h));
if (blit_para.flag_h & 0xff00) {
if (blit_para.flag_h & 0xff00)
{
ret = g2d_blit_h(&blit_para);
}
@@ -756,7 +800,8 @@ int sunxi_g2d_control(int cmd, void *arg)
}
case G2D_CMD_INVERTED_ORDER:
{
if ((enum g2d_scan_order)arg > G2D_SM_DTRL) {
if ((enum g2d_scan_order)arg > G2D_SM_DTRL)
{
G2D_ERR_MSG("scan mode is err.\n");
ret = -EINVAL;
goto err_noput;

View File

@@ -8,7 +8,7 @@ extern "C"
#include <stdint.h>
#include <stddef.h>
#include <interrupt.h>
#include "../../../libos/include/interrupt.h"
typedef enum hal_irqreturn {
HAL_IRQ_OK = (0 << 0),

View File

@@ -333,6 +333,9 @@ struct rt_serial_device
struct rt_spinlock spinlock;
#ifdef RT_USING_SERIAL_BYPASS
struct rt_serial_bypass* bypass;
#endif
struct rt_device_notify rx_notify;
};

View File

@@ -152,10 +152,10 @@ extern "C" {
#include "drivers/dev_serial_v2.h"
#else
#include "drivers/dev_serial.h"
#endif /* RT_USING_SERIAL_V2 */
#ifdef RT_USING_SERIAL_BYPASS
#include "drivers/serial_bypass.h"
#endif /* RT_USING_SERIAL_BYPASS */
#endif
#endif /* RT_USING_SERIAL */
#ifdef RT_USING_I2C

View File

@@ -41,7 +41,11 @@ rt_err_t rt_serial_bypass_init(struct rt_serial_device* serial)
{
serial->bypass = rt_malloc(sizeof(struct rt_serial_bypass));
rt_memset(serial->bypass, 0, sizeof(struct rt_serial_bypass));
#ifdef RT_USING_SERIAL_V2
serial->bypass->pipe = rt_ringbuffer_create(serial->config.rx_bufsz);
#else
serial->bypass->pipe = rt_ringbuffer_create(serial->config.bufsz);
#endif
serial->bypass->mutex = rt_mutex_create("serial_bypass", RT_IPC_FLAG_FIFO);
return RT_EOK;
@@ -140,6 +144,22 @@ static inline rt_err_t _bypass_getchar_form_serial_fifo(struct rt_serial_device*
level = rt_spin_lock_irqsave(&(serial->spinlock));
/* there's no data: */
#ifdef RT_USING_SERIAL_V2
rt_size_t ringbuf_date_stat;
ringbuf_date_stat = rt_ringbuffer_data_len(&rx_fifo->rb);
if(!ringbuf_date_stat)
{
/* no data, enable interrupt and break out */
rt_spin_unlock_irqrestore(&(serial->spinlock), level);
return -RT_EEMPTY;
}
if(!rt_ringbuffer_getchar(&rx_fifo->rb, (rt_uint8_t *)ch))
{
/* Failed to read data */
rt_spin_unlock_irqrestore(&(serial->spinlock), level);
return -RT_EOK;
}
#else
if ((rx_fifo->get_index == rx_fifo->put_index) && (rx_fifo->is_full == RT_FALSE))
{
/* no data, enable interrupt and break out */
@@ -156,7 +176,7 @@ static inline rt_err_t _bypass_getchar_form_serial_fifo(struct rt_serial_device*
{
rx_fifo->is_full = RT_FALSE;
}
#endif
/* enable interrupt */
rt_spin_unlock_irqrestore(&(serial->spinlock), level);