Linux OK6410-Post图像处理器-pp的应用

分析后的PP处理流程.官方只给一个简单中测试程序.简单分析其处理机制,大体按如下流程进行处理.

   1.打开/dev/s3c-pp结点进行操作
   2.对PP的设备使用ioctl命令 ioctl(pp_dev->pp_fd, S3C_PP_SET_PARAMS, &pp_param)来设置缩放前后的分辩率,bpp和格式.其结构定义在 s3c_pp_params_t 之中.
  3. 对pp设备使用ioctl命令ioctl(pp_dev->pp_fd, S3C_PP_ALLOC_KMEM, &alloc_info[0]),分配转换前的在内存.如果输出是LCD的,输出缓冲直接采用显存.
  4.将转换前数据拷贝到转换前内存之中
  5,对于PP调用 ioctl(pp_dev->pp_fd, S3C_PP_START); 进行转换. 
     如果是显存,则直接显示在LCD之上.
  6.退出时,调用ioctl(pp_dev->pp_fd, S3C_PP_FREE_KMEM, &alloc_info[0])  释放转换前的内存.
  7.关闭pp的设备设点
   
  1. #ifndef __S3C_PP_LIB_H__
  2. #define __S3C_PP_LIB_H__
  3. /*
  4.   Author: Andrew Huang <bluedrum@163.com>
  5.     descrition S3C6410 Post Process library 
  6. */

  7. #ifdef __cplusplus
  8. extern "C" {
  9. #endif

  10. typedef enum {
  11.     DMA_ONESHOT,
  12.     FIFO_FREERUN
  13. } s3c_pp_out_path_t;

  14. typedef enum {
  15.     PAL1, PAL2, PAL4, PAL8,
  16.     RGB8, ARGB8, RGB16, ARGB16, RGB18, RGB24, RGB30, ARGB24,
  17.     YC420, YC422, // Non-interleave
  18.     CRYCBY, CBYCRY, YCRYCB, YCBYCR, YUV444 // Interleave
  19. } s3c_color_space_t;

  20. typedef enum {
  21.     INTERLACE_MODE,
  22.     PROGRESSIVE_MODE
  23. } s3c_pp_scan_mode_t;


  24. // Structure type for IOCTL commands S3C_PP_SET_PARAMS, S3C_PP_SET_INPUT_BUF_START_ADDR_PHY, 
  25. // S3C_PP_SET_INPUT_BUF_NEXT_START_ADDR_PHY, S3C_PP_SET_OUTPUT_BUF_START_ADDR_PHY.
  26. typedef struct {
  27.     unsigned int src_full_width;        // Source Image Full Width (Virtual screen size)
  28.     unsigned int src_full_height;        // Source Image Full Height (Virtual screen size)
  29.     unsigned int src_start_x;             // Source Image Start width offset
  30.     unsigned int src_start_y;             // Source Image Start height offset
  31.     unsigned int src_width;                // Source Image Width
  32.     unsigned int src_height;             // Source Image Height
  33.     unsigned int src_buf_addr_phy;         // Base Address of the Source Image : Physical Address
  34.     unsigned int src_next_buf_addr_phy; // Base Address of Source Image to be displayed next time in FIFO_FREERUN Mode
  35.     s3c_color_space_t src_color_space;     // Color Space of the Source Image

  36.     unsigned int dst_full_width;         // Destination Image Full Width (Virtual screen size)
  37.     unsigned int dst_full_height;         // Destination Image Full Height (Virtual screen size)
  38.     unsigned int dst_start_x;             // Destination Image Start width offset
  39.     unsigned int dst_start_y;             // Destination Image Start height offset
  40.     unsigned int dst_width;             // Destination Image Width
  41.     unsigned int dst_height;             // Destination Image Height
  42.     unsigned int dst_buf_addr_phy;        // Base Address of the Destination Image : Physical Address
  43.     s3c_color_space_t dst_color_space;     // Color Space of the Destination Image

  44.     s3c_pp_out_path_t out_path;      // output and run mode (DMA_ONESHOT or FIFO_FREERUN)
  45.     s3c_pp_scan_mode_t scan_mode; // INTERLACE_MODE, PROGRESSIVE_MODE
  46. } s3c_pp_params_t;

  47. // Structure type for IOCTL commands S3C_PP_ALLOC_KMEM, S3C_PP_FREE_KMEM.
  48. typedef struct {
  49.     int         size;
  50.     unsigned int     vir_addr;
  51.     unsigned int     phy_addr;
  52. } s3c_pp_mem_alloc_t;

  53. #define PP_IOCTL_MAGIC 'P'

  54. #define S3C_PP_SET_PARAMS             _IO(PP_IOCTL_MAGIC, 0)
  55. #define S3C_PP_START                     _IO(PP_IOCTL_MAGIC, 1)
  56. #define S3C_PP_GET_SRC_BUF_SIZE          _IO(PP_IOCTL_MAGIC, 2)
  57. #define S3C_PP_SET_SRC_BUF_ADDR_PHY _IO(PP_IOCTL_MAGIC, 3)
  58. #define S3C_PP_SET_SRC_BUF_NEXT_ADDR_PHY _IO(PP_IOCTL_MAGIC, 4)
  59. #define S3C_PP_GET_DST_BUF_SIZE          _IO(PP_IOCTL_MAGIC, 5)
  60. #define S3C_PP_SET_DST_BUF_ADDR_PHY     _IO(PP_IOCTL_MAGIC, 6)
  61. #define S3C_PP_ALLOC_KMEM _IO(PP_IOCTL_MAGIC, 7)
  62. #define S3C_PP_FREE_KMEM _IO(PP_IOCTL_MAGIC, 8)
  63. #define S3C_PP_GET_RESERVED_MEM_SIZE _IO(PP_IOCTL_MAGIC, 9)
  64. #define S3C_PP_GET_RESERVED_MEM_ADDR_PHY _IO(PP_IOCTL_MAGIC, 10)

  65. struct video_view {
  66.   int x;
  67.   int y;
  68.   int w;
  69.   int h;
  70.   int bpp;
  71.   int format;
  72.   char * buf;
  73.   int size; 
  74.   char * phy_addr;
  75. };

  76.  struct fb_pp {
  77.       struct video_view fb_view;
  78.      struct video_view src_view;
  79.      int fb_fd;
  80.      int pp_fd;
  81.      int out_path;
  82.      int scan_mode;
  83.      s3c_pp_params_t    pp_param;
  84.      };

  85.  typedef struct
  86. {
  87.     unsigned int map_dma_f1;
  88.     unsigned int map_dma_f2;
  89. } s3c_fb_dma_info_t;

  90. extern int s3c_pp_setup(struct fb_pp * pp_dev,struct video_view * src,int out_path);
  91. extern int s3c_pp_open(struct fb_pp * pp_dev,int bpp);
  92. extern int s3c_pp_write(struct fb_pp * pp_dev,char * buf,int buf_len);

  93. extern int s3c_pp_write_file(struct fb_pp * pp_dev,char * filename);

  94. extern int s3c_pp_apply(struct fb_pp * pp_dev);

  95. #ifdef __cplusplus
  96. }
  97. #endif

  98. #endif /* __S3C_PP_LIB_H__ */
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
要在Linux系统上部署Chat-GLM-6B-Int4,需要按照以下步骤进行操作: 1. 安装TensorFlow Serving:可以通过Docker安装TensorFlow Serving,也可以从源代码安装。 2. 获取并转换模型:从Hugging Face下载Chat-GLM-6B-Int4模型,然后使用TensorFlow模型转换将其转换为TensorFlow格式。 3. 部署模型:将转换后的模型放在TensorFlow Serving的模型目录中,并启动TensorFlow Serving。 4. 测试模型:使用gRPC或REST API测试模型是否正常工作。 以下是详细的步骤: 1. 安装TensorFlow Serving 可以通过Docker安装TensorFlow Serving,以下是安装命令: ```bash docker pull tensorflow/serving ``` 也可以从源代码安装,可以参考官方文档:https://www.tensorflow.org/tfx/serving/setup 2. 获取并转换模型 从Hugging Face下载Chat-GLM-6B-Int4模型,可以使用以下命令: ```bash wget https://huggingface.co/microsoft/DialoGPT-medium/resolve/main/checkpoint-4 ``` 然后使用TensorFlow模型转换将其转换为TensorFlow格式,使用以下命令: ```bash pip install tensorflow==2.5.0 pip install tensorflow-text==2.5.0 git clone https://github.com/huggingface/transformers.git cd transformers python ./examples/research_projects/tf-gpt2-convert-tf2.py \ --tf_checkpoint ./checkpoint-4 \ --config_file ./microsoft/DialoGPT-medium/config.json \ --py_output_path ./models/dialogpt_medium.py \ --tf_output_path ./models/dialogpt_medium \ --batch_size 1 \ --use_tpu False ``` 3. 部署模型 将转换后的模型放在TensorFlow Serving的模型目录中,可以使用以下命令: ```bash mkdir -p /models/dialogpt_medium cp ./models/dialogpt_medium.* /models/dialogpt_medium/ ``` 然后启动TensorFlow Serving,以下是启动命令: ```bash docker run -p 8501:8501 \ --mount type=bind,source=/models/dialogpt_medium,target=/models/dialogpt_medium \ -e MODEL_NAME=dialogpt_medium \ -t tensorflow/serving ``` 4. 测试模型 使用gRPC或REST API测试模型是否正常工作,以下是REST API测试命令: ```bash curl -d '{"instances": [{"input_text": "Hello, how are you?"}]}' \ -X POST http://localhost:8501/v1/models/dialogpt_medium:predict ``` 如果一切正常,应该可以看到模型返回的响应。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值