2.KMD-20.ARMMalidp-《计算机知识》

admin 2025-11-02 22:34:28 系统网络 来源:ZONE.CI 全球网 0 阅读模式
  • 内容和参考
    • 内容
    • 参考
  • 系统框架
  • 软件流程
  • 软件代码
    • 设备树配置
    • 编译选项
    • 代码流程
      • malidp软件框架
      • malidp初始化流程
      • malidp crtc初始化流程

    内容和参考

    内容

    参考

    • linux源码国内源下载, Linux源码GitHub,

    系统框架

    软件流程

    软件代码

    设备树配置

    参考文档:Documentation/devicetree/bindings/display/arm,malidp.txt

    编译选项

    1. mali-dp-y := malidp_drv.o malidp_hw.o malidp_planes.o malidp_crtc.o
    2. mali-dp-y += malidp_mw.o

    代码流程

    malidp软件框架

    malidp初始化流程

    1. malidp_bind // component 组件的master
    2. // 1. 分配私有数据结构体
    3. malidp = devm_kzalloc(dev, sizeof(*malidp), GFP_KERNEL);
    4. hwdev = devm_kzalloc(dev, sizeof(*hwdev), GFP_KERNEL);
    5. // 2. (重点)根据设备树匹配相应的硬件 platform data数据信息 ; malidp_drm_of_match 里边的 .data = &malidp_device[MALIDP_550]
    6. hwdev->hw = (struct malidp_hw *)of_device_get_match_data(dev);
    7. // 可选:获取reserved内存 作为framebuffer
    8. of_reserved_mem_device_init(dev);
    9. // 3. drm框架-分配drm_device
    10. drm_dev_alloc(&malidp_driver, dev);
    11. // 检测 寄存器空间大小 resouce_size 是否够用
    12. malidp_has_sufficient_address_space(res, dev_id)
    13. // 4. 硬件相关:malidp550_query_hw 根据 CONFIGURATION_ID 获取 max/min line size
    14. // 支持三种配置: 2x2 - 1280x1280 pixels的HD配置,2x2 - 2048x2048 的2K配置,2x2 - 4096x4096 的4K配置,
    15. hwdev->hw->query_hw(hwdev);
    16. hwdev->min_line_size = 2;
    17. hwdev->max_line_size = SZ_2K/SZ_4K/1280;
    18. hwdev->rotation_memory[0] = hwdev->rotation_memory[1] = rsize * SZ_1K;
    19. // 5. 硬件相关:从 MALIDP_DE_CORE_ID 获取Core ID信息
    20. malidp_hw_read(hwdev, hwdev->hw->map.dc_base + MALIDP_DE_CORE_ID);
    21. // 6. ??? TBD:
    22. // .out_depth_base = MALIDP550_DE_OUTPUT_DEPTH, 指定启用抖动操作时的输出颜色深度。
    23. // [19:16] OUT_DEPTH_R Red component output color depth for dithering process.
    24. // [11:8] OUT_DEPTH_G Green component output color depth for dithering process.
    25. // [3:0] OUT_DEPTH_B Blue component output color depth for dithering process.
    26. of_property_read_u32(dev->of_node,"arm,malidp-arqos-value",&hwdev->arqos_value)
    27. of_property_read_u8_array(dev->of_node,"arm,malidp-output-port-lines",output_width, MAX_OUTPUT_CHANNELS);
    28. for (i = 0; i < MAX_OUTPUT_CHANNELS; i++)
    29. out_depth = (out_depth << 8) | (output_width[i] & 0xf);
    30. malidp_hw_write(hwdev, out_depth, hwdev->hw->map.out_depth_base); // MALIDP550_DE_OUTPUT_DEPTH 寄存器
    31. hwdev->output_color_depth = out_depth;
    32. // 7. 重点:kms init ,参考后边:malidp crtc初始化流程
    33. malidp_init(drm)
    34. // 8. 等待 port 完成初始化
    35. component_bind_all(dev, drm);
    36. // 9. 硬件相关:中断初始化
    37. // mali-dp550支持2-4路中断,(因为支持1-2路显示)
    38. // • IRQDE0. Interrupt request signal from the primary display core and primary display engine.
    39. // • IRQDE1. Interrupt request signal from the secondary display core and secondary display engine. Not
    40. // used in single display configuration.
    41. // • IRQSE0. Interrupt request signal from the primary scaling engine.
    42. // • IRQSE1. Interrupt request signal from the secondary scaling engine: Not used in single display configuration.
    43. malidp_irq_init(pdev);
    44. // 10. vblank初始化,后续详解
    45. drm_vblank_init(drm, drm->mode_config.num_crtc);
    46. // 11. kms初始化,后续详解
    47. drm_mode_config_reset(drm);
    48. drm_kms_helper_poll_init(drm);
    49. // 12. drm_device 注册
    50. drm_dev_register(drm, 0);
    51. // 13.???
    52. drm_fbdev_generic_setup(drm, 32);

    malidp crtc初始化流程

    1. // 官方流程:初始化 (struct drm_mode_config *) drm_device->mode_config 空间
    2. // 释放调用: drm_mode_config_cleanup(drm);
    3. drm_mode_config_init(drm);
    4. // 初始化硬件显示分辨率 及 操作接口
    5. // 用户空间调用 drmIoctl(fd, DRM_IOCTL_MODE_GETRESOURCES, &res) 可获取到对应分辨率信息
    6. drm->mode_config.min_width = hwdev->min_line_size;
    7. drm->mode_config.min_height = hwdev->min_line_size;
    8. drm->mode_config.max_width = hwdev->max_line_size;
    9. drm->mode_config.max_height = hwdev->max_line_size;
    10. drm->mode_config.funcs = &malidp_mode_config_funcs;
    11. drm->mode_config.helper_private = &malidp_mode_config_helpers;
    12. drm->mode_config.allow_fb_modifiers = true;
    13. drmm_mode_config_init
    14. drm->mode_config.xxx ; // drm->mode_config 初始化结构体
    15. malidp_crtc_init(drm); // !!! modeset 初始化结构体,难点
    16. malidp_de_planes_init(drm); //
    17. // skip:if (!(map->features & MALIDP_DEVICE_AFBC_SUPPORT_SPLIT)); // DP550支持 MALIDP_DEVICE_AFBC_SUPPORT_SPLIT
    18. // 根据 malidp_device 的 malidp550_layers 和 每一层 malidp550_de_formats 来初始化plane
    19. // DP550支持4层layer: DE_VIDEO1, DE_GRAPHICS1, DE_VIDEO2, DE_SMART, VIDE01是Primary,其他都是Overlay,SMART显示在最上层
    20. // 每层都支持 MALIDP_COMMON_FORMATS 格式
    21. drm_universal_plane_init();
    22. drm_plane_helper_add();
    23. drm_plane_create_alpha_property();
    24. drm_plane_create_blend_mode_property();
    25. drm_plane_create_rotation_property();
    26. // 硬件相关:LV1_CONTROL 配置 对应 video 层的合成参数 ??? TBD
    27. malidp_hw_write(malidp->dev, MALIDP_ALPHA_LUT,plane->layer->base + MALIDP_LAYER_COMPOSE);
    28. // LV1和LV2支持 Attach the YUV->RGB property only to video layers
    29. drm_plane_create_color_properties();
    30. malidp_mw_connector_init(drm);