我希望使用小核运行lvgl对大核程序进行控制,运行小核lvgldemo的时候发现linux下的屏幕没有做适配,查看dts发现几乎所有的dts都用的是hx8399作为dsi的显示,但是现在市面上的开发板配套的屏幕都没有hx8399,我应该如何去适配一个自己的屏幕。可以的话我希望能够适配自己的第三方的屏幕,已经在大核上调通能用点亮运行。linux下的适配遇到了困难。
软硬件版本信息
立创庐山派,linux+rt-smart双系统。
错误日志
尝试解决过程
补充材料
我希望使用小核运行lvgl对大核程序进行控制,运行小核lvgldemo的时候发现linux下的屏幕没有做适配,查看dts发现几乎所有的dts都用的是hx8399作为dsi的显示,但是现在市面上的开发板配套的屏幕都没有hx8399,我应该如何去适配一个自己的屏幕。可以的话我希望能够适配自己的第三方的屏幕,已经在大核上调通能用点亮运行。linux下的适配遇到了困难。
软硬件版本信息
立创庐山派,linux+rt-smart双系统。
错误日志
尝试解决过程
补充材料
有的、年可以在看一下
linux+rt-smart系统下的sdk就是没有
这个驱动要自己添加,放到这个路径下/home/k230_sdk/src/little/linux/arch/riscv/boot/dts/kendryte/display_st7701_480*800.dtsi
&vo {
vth_line = <10>;
};
&dsi {
status = "okay";
ports {
port@1 {
reg = <1>;
dsi_out_st7701: endpoint {
remote-endpoint = <&st7701_in>;
};
};
};
lcd: panel@0 {
status = "okay";
compatible = "canaan,st7701";
reg = <0>;
panel-width-mm = <480>;
panel-height-mm = <800>;
panel-dsi-lane = <2>;
panel-init-sequence = [
39 00 06 ff 77 01 00 00 13
39 00 02 ef 08
39 00 06 ff 77 01 00 00 10
39 00 03 c0 63 00
39 00 03 c1 10 02
39 00 03 c2 31 02
39 00 02 cc 10
39 00 11 b0 c0 0c 92 0c 10 05 02 0d 07 21 04 53 11 6a 32 1f
39 00 11 b1 c0 87 cf 0c 10 06 00 03 08 1d 06 54 12 e6 ec 0f
39 00 06 ff 77 01 00 00 11
39 00 02 b0 5d
39 00 02 b1 62
39 00 02 b2 82
39 00 02 b3 80
39 00 02 b5 42
39 00 02 b7 85
39 00 02 b8 20
39 00 02 c0 09
39 00 02 c1 78
39 00 02 c2 78
39 00 02 d0 88
39 ff 02 ee 42
39 00 04 e0 00 00 02
39 00 0c e1 04 a0 06 a0 05 a0 07 a0 00 44 44
39 00 0d e2 00 00 33 33 01 a0 00 00 01 a0 00 00
39 00 05 e3 00 00 33 33
39 00 03 e4 44 44
39 00 11 e5 0c 30 a0 a0 0e 32 a0 a0 08 2c a0 a0 0a 2e a0 a0
39 00 05 e6 00 00 33 33
39 00 03 e7 44 44
39 00 11 e8 0d 31 a0 a0 0f 33 a0 a0 09 2d a0 a0 0b 2f a0 a0
39 00 08 eb 00 01 e4 e4 44 88 00
39 00 11 ed ff f5 47 6f 0b a1 a2 bf fb 2a 1a b0 f6 74 5f ff
39 00 07 ef 08 08 08 40 3f 64
39 00 06 ff 77 01 00 00 13
39 00 03 e8 00 0e
39 00 06 ff 77 01 00 00 00
39 ff 01 11
39 00 06 ff 77 01 00 00 13
39 ff 03 e8 00 0c
39 00 03 e8 00 00
39 00 06 ff 77 01 00 00 00
39 00 02 3a 50
39 ff 01 29
];
display-timings {
timing-0 {
clock-frequency = <39600000>;
hactive = <480>;
vactive = <800>;
hfront-porch = <80>;
hback-porch = <20>;
hsync-len = <20>;
vfront-porch = <220>;
vback-porch = <70>;
vsync-len = <10>;
};
};
ports {
#address-cells = <1>;
#size-cells = <0>;
port@0 {
reg = <0>;
st7701_in: endpoint {
remote-endpoint = <&dsi_out_st7701>;
};
};
};
};
};
k230_canmv_lckfb.dts这个文件内也要改
/* Copyright (c) 2023, Canaan Bright Sight Co., Ltd
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*/
#include "k230.dtsi"
#include "clock_provider.dtsi" /* k230 soc clock tree */
#include "clock_consumer.dtsi" /* k230 soc clock consumer */
#include "reset_provider.dtsi" /* k230 soc reset provider */
#include "reset_consumer.dtsi" /* k230 soc reset consumer */
#include "power_provider.dtsi" /* k230 soc power provider */
#include "power_consumer.dtsi" /* k230 soc power consumer */
#include "gpio_provider.dtsi" /* k230 soc gpio provider */
#include "gpio_consumer.dtsi" /* k230 soc gpio consumer */
#include "display_st7701_480*800.dtsi"
/ {
aliases {
serial0 = &uart0;
};
chosen {
bootargs = "";
linux,initrd-start = <0x0 0xa100000>;
linux,initrd-end = <0x0 0x0>;
stdout-path = "serial0:115200";
};
sound {
status = "disable";
compatible = "canaan,k230-audio-inno";
canaan,model = "CANAAN_K230_I2S_INNO";
canaan,k230-i2s-controller = <&i2s>;
canaan,k230-audio-codec = <&inno_codec>;
};
};
&ddr {
reg = <0x0 0x8200000 0x0 0x7dff000>; /*linux memory config*/
};
&usbotg0 {
status = "okay";
};
&usbotg1 {
dr_mode = "host";
status = "okay";
};
&mmc_sd0{
status = "okay";
rx_delay_line = <0x0d>;
tx_delay_line = <0xc0>;
};
&mmc_sd1{
status = "okay";
no-1-8-v;
cap-sd-highspeed;
mshc_ctrl_r = <0x00>;
};
/*&dsi {
status = "okay";
panel@0 {
compatible = "canaan,hx8399";
reg = <0>;
display-timings {
timing-0 {
clock-frequency = <74250000>;
hactive = <1920>;
vactive = <1080>;
hfront-porch = <88>;
hback-porch = <148>;
hsync-len = <44>;
vfront-porch = <36>;
vback-porch = <4>;
vsync-len = <5>;
};
};
};
};*/
&uart0 {
status = "okay";
};
/home/k230_sdk/src/little/linux/drivers/gpu/drm/panel/panel-canaan-universal.c这个路径下的这个.c文件也要改
// SPDX-License-Identifier: GPL-2.0-only
/*
* Copyright (C) 2022, Canaan Bright Sight Co., Ltd
*
* All enquiries to https://www.canaan-creative.com/
*
*/
#include <linux/delay.h>
#include <linux/device.h>
#include <linux/err.h>
#include <linux/errno.h>
#include <linux/fb.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/of_device.h>
#include <linux/gpio/consumer.h>
#include <linux/regulator/consumer.h>
#include <drm/drm_mipi_dsi.h>
#include <drm/drm_modes.h>
#include <drm/drm_panel.h>
#include <video/mipi_display.h>
#include <video/of_videomode.h>
#include <video/videomode.h>
struct canaan_panel_instr {
char cmd;
char data;
};
struct canaan_panel_desc {
const struct canaan_panel_instr *init;
const size_t init_length;
//const struct drm_display_mode *mode;
};
struct canaan_panel {
struct drm_panel panel;
struct mipi_dsi_device *dsi;
const struct canaan_panel_desc *desc;
struct regulator *power;
struct gpio_desc *reset;
struct videomode vm;
u32 width_mm;
u32 height_mm;
};
static const struct canaan_panel_instr hx8399_init[] = {
};
static const struct canaan_panel_instr st7701_init[] = {
// 填写你的 ST7701 初始化命令
};
static inline struct canaan_panel *panel_to_canaan_panel(struct drm_panel *panel)
{
return container_of(panel, struct canaan_panel, panel);
}
static int canaan_panel_prepare(struct drm_panel *panel)
{
return 0;
}
static int canaan_panel_enable(struct drm_panel *panel)
{
return 0;
}
static int canaan_panel_disable(struct drm_panel *panel)
{
return 0;
}
static int canaan_panel_unprepare(struct drm_panel *panel)
{
return 0;
}
static int canaan_panel_get_modes(struct drm_panel *panel,
struct drm_connector *connector)
{
struct canaan_panel *ctx = panel_to_canaan_panel(panel);
struct drm_display_mode *mode;
mode = drm_mode_create(connector->dev);
if (!mode) {
dev_err(panel->dev, "failed to create a new display mode\n");
return 0;
}
drm_display_mode_from_videomode(&ctx->vm, mode);
mode->width_mm = ctx->width_mm;
mode->height_mm = ctx->height_mm;
connector->display_info.width_mm = mode->width_mm;
connector->display_info.height_mm = mode->height_mm;
mode->type = DRM_MODE_TYPE_DRIVER | DRM_MODE_TYPE_PREFERRED;
drm_mode_probed_add(connector, mode);
return 1;
}
static const struct drm_panel_funcs canaan_panel_funcs = {
.prepare = canaan_panel_prepare,
.unprepare = canaan_panel_unprepare,
.enable = canaan_panel_enable,
.disable = canaan_panel_disable,
.get_modes = canaan_panel_get_modes,
};
static int canaan_panel_parse_dt(struct canaan_panel *ctx)
{
struct device *dev = &ctx->dsi->dev;
struct device_node *np = dev->of_node;
int ret;
ret = of_get_videomode(np, &ctx->vm, 0);
if (ret < 0)
return ret;
of_property_read_u32(np, "panel-width-mm", &ctx->width_mm);
of_property_read_u32(np, "panel-height-mm", &ctx->height_mm);
return 0;
}
static int canaan_panel_dsi_probe(struct mipi_dsi_device *dsi)
{
struct canaan_panel *ctx;
int ret;
ctx = devm_kzalloc(&dsi->dev, sizeof(*ctx), GFP_KERNEL);
if (!ctx)
return -ENOMEM;
mipi_dsi_set_drvdata(dsi, ctx);
ctx->dsi = dsi;
ctx->desc = of_device_get_match_data(&dsi->dev);
ret = canaan_panel_parse_dt(ctx);
if (ret < 0)
return ret;
// Panel Device Tree Read..
dsi->mode_flags = MIPI_DSI_MODE_VIDEO_SYNC_PULSE;
dsi->format = MIPI_DSI_FMT_RGB888;
dsi->lanes = 4;
drm_panel_init(&ctx->panel, &dsi->dev, &canaan_panel_funcs,
DRM_MODE_CONNECTOR_DSI);
drm_panel_add(&ctx->panel);
ret = mipi_dsi_attach(dsi);
if (ret) {
drm_panel_remove(&ctx->panel);
}
return ret;
}
static int canaan_panel_dsi_remove(struct mipi_dsi_device *dsi)
{
struct canaan_panel *ctx = mipi_dsi_get_drvdata(dsi);
mipi_dsi_detach(dsi);
drm_panel_remove(&ctx->panel);
return 0;
}
static const struct canaan_panel_desc hx8399_desc = {
// .init = hx8399_init,
// .init_length = ARRAY_SIZE(hx8399_init),
// .mode = &hx8399_default_mode,
};
static const struct canaan_panel_desc st7701_desc = {
// .init = st7701_init,
// .init_length = ARRAY_SIZE(st7701_init),
};
static const struct of_device_id canaan_panel_of_match[] = {
{ .compatible = "canaan,hx8399", .data = &hx8399_desc },
{ .compatible = "canaan,st7701", .data = &st7701_desc },
{ }
};
MODULE_DEVICE_TABLE(of, canaan_panel_of_match);
static struct mipi_dsi_driver canaan_panel_driver = {
.probe = canaan_panel_dsi_probe,
.remove = canaan_panel_dsi_remove,
.driver = {
.name = "canaan-panel-dsi",
.of_match_table = canaan_panel_of_match,
},
};
module_mipi_dsi_driver(canaan_panel_driver);
MODULE_AUTHOR("");
MODULE_DESCRIPTION("Canaan K230 Panel Driver");
MODULE_LICENSE("GPL");
这样就可以点亮了,横屏应该换一下宽跟高应该就可以了吧,没试过,不过要注意加了这个只是显示可以了,触摸就没有,应该得额外整