isp_dmsc.c 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. /*
  2. * Copyright (C) 2021 Alibaba Group Holding Limited
  3. * Author: LuChongzhi <chongzhi.lcz@alibaba-inc.com>
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License version 2 as
  7. * published by the Free Software Foundation.
  8. */
  9. #include <stdio.h>
  10. #include <stdlib.h>
  11. #include <stdint.h>
  12. #include <unistd.h>
  13. #include <string.h>
  14. #include "ra_common.h"
  15. #define REG_BASE 0x00003e00
  16. static const reg_field_s reg_desc[] = {
  17. /* structure field order
  18. reg_name, offset,reset_value,msb,lsb, field_name, field_desc */
  19. {"ISP_DMSC_CTRL", "Demosaic control register",
  20. 0x00003E00, 0x0400288E, 31, 24, "demosaic_thr", "Threshold for Bayer demosaicing texture detection." LINE_PADDING_6TAB
  21. " This value shifted 4-bit is compared width the different of the vertical" LINE_PADDING_6TAB
  22. " and horizontal 12bit wide texture indicators, to decide if the vertical or" LINE_PADDING_6TAB
  23. " horizontal texture flag must be set." LINE_PADDING_6TAB
  24. "0x00: maximum edge sensitivity" LINE_PADDING_6TAB
  25. "0xff: no texture detection"},
  26. {NULL, NULL, 0x00003E00, 0x0400288E, 21, 16, "denoise_strength", "green channel smoothing filter results account for the weight of the final result, the larger the blur"},
  27. {NULL, NULL, 0x00003E00, 0x0400288E, 14, 14, "frame_clr_sel", "0:frame clear by vsync. 1:frame clear by frame end"},
  28. {NULL, NULL, 0x00003E00, 0x0400288E, 13, 13, "frame_end_en", "frame clear by frame end"},
  29. {NULL, NULL, 0x00003E00, 0x0400288E, 12, 8, "sharpen_size", "green channel sharpen size, the larger the sharpen edge, the greater the graininess"},
  30. {NULL, NULL, 0x00003E00, 0x0400288E, 7, 7, "vsync_pos_en", "frame clear by VSYNC"},
  31. {NULL, NULL, 0x00003E00, 0x0400288E, 6, 6, "soft_rst_inner", "soft reset"},
  32. {NULL, NULL, 0x00003E00, 0x0400288E, 5, 5, "sharpen_line_enable", "0: disable line sharpen, 1: enable line sharpen"},
  33. {NULL, NULL, 0x00003E00, 0x0400288E, 4, 4, "skin_enable", "0: disable skin area filter, 1: enable skin area filter"},
  34. {NULL, NULL, 0x00003E00, 0x0400288E, 3, 3, "depurple_enable", "0: disable depurple, 1: enable depurple"},
  35. {NULL, NULL, 0x00003E00, 0x0400288E, 2, 2, "demoire_enable", "0: disable demoire, 1: enable demoire"},
  36. {NULL, NULL, 0x00003E00, 0x0400288E, 1, 1, "sharpen_enable", "0: disable sharpen, 1: enable sharpen"},
  37. {NULL, NULL, 0x00003E00, 0x0400288E, 0, 0, "demosaic_bypass", "0: do interpolation, 1: bypass interpolation"},
  38. {"ISP_DMSC_INTP_THR", "Direction select threshold register",
  39. 0x00003E04, 0x00000000, 23, 12, "interplationdir_thr_max", "direction select threshold value in bright area, the interpolation " LINE_PADDING_6TAB
  40. " operation between maximum threshold and minimal threshold"},
  41. {NULL, NULL, 0x00003E04, 0x00000000, 11, 0, "interplationdir_thr_min", "direction select threshold value in dark area, the interpolation " LINE_PADDING_6TAB
  42. " operation between maximum threshold and minimal threshold"},
  43. {"ISP_DMSC_DMOI_CTRL", "Demoire ctrl register",
  44. 0x00003E08, 0x00001F08, 13, 8, "demoire_area_thr", "judgment threshold of moire area"},
  45. {NULL, NULL, 0x00003E08, 0x00001F08, 5, 0, "demoire_sat_shrink", "moire pixel forced saturation, 32=no color"},
  46. {"ISP_DMSC_CAC_CTRL", "Control register for chromatic aberration correction",
  47. 0x00003E44, 0x00000000, 3, 3, "cac_h_clip_mode", "defines the red/blue pixel shift in horizon direction" LINE_PADDING_6TAB
  48. "0:set horizon vector to +/-4 pixel" LINE_PADDING_6TAB
  49. "1:set horizon vector to +/-4 or +/-5 pixel " LINE_PADDING_6TAB
  50. " depending on the position in bayer raster"},
  51. {NULL, NULL, 0x00003E44, 0x00000000, 2, 1, "cac_v_clip_mode", "defines the red/blue pixel shift in vertical direction" LINE_PADDING_6TAB
  52. "00:set vertical vector to +/-2 pixel" LINE_PADDING_6TAB
  53. "01:set vertical vector to +/-3 pixel" LINE_PADDING_6TAB
  54. "10:set vertical vector to +/-3 or +/-4 pixel " LINE_PADDING_6TAB
  55. " depending on the position in bayer raster" LINE_PADDING_6TAB
  56. "11:reserved"},
  57. {NULL, NULL, 0x00003E44, 0x00000000, 0, 0, "cac_enable", "0: chromatic aberration correction off" LINE_PADDING_6TAB
  58. "1: chromatic aberration correction on"},
  59. {"ISP_DMSC_SIZE_CTRL", "demoire size ctrl register",
  60. 0x00003E60, 0x01000000, 31, 16, "dummy_hblk_value", "dummy lines hblank cycles"},
  61. {NULL, NULL, 0x00003E60, 0x01000000, 15, 0, "img_hsize", "dmsc process image hsize"},
  62. {"ISP_DMSC_SHAP_FACT", "Sharpen factor register",
  63. 0x00003E14, 0x00008008, 20, 12, "sharpen_factor_black", "Sharpen factor of black edge; 0 means no sharpen"},
  64. {NULL, NULL, 0x00003E14, 0x00008008, 8, 0, "sharpen_factor_white", "Sharpen factor of white edge; 0 means no sharpen"},
  65. {"ISP_DMSC_CTRL_SHD", "Demosaic control shadow register",
  66. 0x00003E64, 0x0400080E, 31, 24, "demosaic_thr", "Threshold for Bayer demosaicing texture detection." LINE_PADDING_6TAB
  67. " This value shifted 4-bit is compared width the different of the vertical" LINE_PADDING_6TAB
  68. " and horizontal 12bit wide texture indicators, to decide if the vertical or" LINE_PADDING_6TAB
  69. " horizontal texture flag must be set." LINE_PADDING_6TAB
  70. "0x00: maximum edge sensitivity" LINE_PADDING_6TAB
  71. "0xff: no texture detection"},
  72. {NULL, NULL, 0x00003E64, 0x0400080E, 21, 16, "denoise_strength", "green channel smoothing filter results account for the weight of the final result, the larger the blur"},
  73. {NULL, NULL, 0x00003E64, 0x0400080E, 14, 14, "frame_clr_sel", "0:frame clear by vsync. 1:frame clear by frame end"},
  74. {NULL, NULL, 0x00003E64, 0x0400080E, 13, 13, "frame_end_en", "frame clear by frame end"},
  75. {NULL, NULL, 0x00003E64, 0x0400080E, 12, 8, "sharpen_size", "green channel sharpen size, the larger the sharpen edge, the greater the graininess"},
  76. {NULL, NULL, 0x00003E64, 0x0400080E, 7, 7, "vsync_pos_en", "frame clear by VSYNC"},
  77. {NULL, NULL, 0x00003E64, 0x0400080E, 6, 6, "soft_rst_inner", "soft reset"},
  78. {NULL, NULL, 0x00003E64, 0x0400080E, 5, 5, "sharpen_line_enable", "0: disable line sharpen, 1: enable line sharpen"},
  79. {NULL, NULL, 0x00003E64, 0x0400080E, 4, 4, "skin_enable", "0: disable skin area filter, 1: enable skin area filter"},
  80. {NULL, NULL, 0x00003E64, 0x0400080E, 3, 3, "depurple_enable", "0: disable depurple, 1: enable depurple"},
  81. {NULL, NULL, 0x00003E64, 0x0400080E, 2, 2, "demoire_enable", "0: disable demoire, 1: enable demoire"},
  82. {NULL, NULL, 0x00003E64, 0x0400080E, 1, 1, "sharpen_enable", "0: disable sharpen, 1: enable sharpen"},
  83. {NULL, NULL, 0x00003E64, 0x0400080E, 0, 0, "demosaic_bypass", "0: do interpolation, 1: bypass interpolation"},
  84. };
  85. int light_isp_dmsc_reg_dump(reg_analyzer_info_s *ra_info)
  86. {
  87. uint32_t count = sizeof(reg_desc) / sizeof(reg_desc[0]);
  88. return ra_dump_reg_fields(ra_info, reg_desc, count);
  89. }
  90. int light_isp_dmsc_reg_define(reg_analyzer_info_s *ra_info)
  91. {
  92. uint32_t count = sizeof(reg_desc) / sizeof(reg_desc[0]);
  93. return ra_dump_reg_define(ra_info, reg_desc, count);
  94. }
  95. int light_isp_dmsc_reg_find(reg_analyzer_info_s *ra_info)
  96. {
  97. uint32_t count = sizeof(reg_desc) / sizeof(reg_desc[0]);
  98. return ra_dump_reg_find(ra_info, reg_desc, count);
  99. }