About rk3066&rk3188 BOX 4.4.2 SDK, external USB camera, pixel set to 5 million, the lower right corner of the picture appears small rectangular color block.

Source: Internet
Author: User

1. Questions

See figure:


And

2. Solution

Diff--git A/hardware/rk29/camera/camerahal_utils.cpp B/hardware/rk29/camera/camerahal_utils.cppindex 5b62f9d. A2423d7 100755---a/hardware/rk29/camera/camerahal_utils.cpp+++ b/hardware/rk29/camera/camerahal_utils.cpp@@- 193,7 +193,7 @@ extern "C" int Rk_camera_zoom_ipp (int v4l2_fmt_src, int srcbuf, int src_w, int s        ipp_req.flag = Ipp_ro T_0;         Ipp_req.store_clip_mode =1;        IPP_REQ.SRC0.W = cropw/scale_w_times;-       ipp_req.src0.h = croph/scale_h_times;+       ipp_req.src0.h = CropH/scale_h _times-8;        Ipp_req.src_vir_w = Src_w;        IPP_REQ.SRC0.FMT = ipp_y_cbcr_h2v2;        IPP_REQ.DST0.W = Src_w/scale_w_times;diff--git a/hardware/rk29/camera/messagequeue.cpp b/hardware/rk29/camera/ Messagequeue.cppindex 61ee1f6. 545f1d8 100755---a/hardware/rk29/camera/messagequeue.cpp+++ b/hardware/rk29/camera/messagequeue.cpp@@ -276,4 + 276,3 @@ int MessageQueue::d UMP ()     return 0;}


Also refer to the following documents:

In today's 312x chip code, take a few rows:
1):
In Rk_camera_setup_format ():
else{/* This is one frame mode*/
Rect->width-= 50;
Rect->height-= 8;
Cif_crop = (Rect->left + (Rect->top <<16));
Cif_fs= ((Rect->width) + ((rect->height) <<16));
}
Write_cif_reg (Pcdev->base,cif_cif_crop, Cif_crop);
Write_cif_reg (Pcdev->base,cif_cif_set_size, CIF_FS);
Write_cif_reg (Pcdev->base,cif_cif_vir_line_width, rect->width);
Write_cif_reg (Pcdev->base,cif_cif_frame_status, 0x00000003);


Change to: Cif_fs= ((rect->width-8) + ((rect->height-8) <<16));
And not directly in front:
Rect->width-= 8;
Rect->height-= 8;


Here Rect->width value is also written after the virtual width register, this value determines the width of each row acquisition, if the acquisition width of the cif_cif_set_size set is less than the void, then each line after 0, that is, see the green;
(RECT-&GT;HEIGHT-8), indicating that each frame is less than 8 rows, is also 0; here in fact (rect->width-8), not necessarily, each line does not have to collect less;


However, this change will affect the predecessor, so the Oneframe is not modified or modified in the post-sp2518.c file:
static int sensor_s_fmt_cb_th (struct i2c_client *client,struct v4l2_mbus_framefmt *MF, bool capture)
{
Sensor_tr ("--hkw--mf->widthh (%dx%d)-----\ n", mf->width,mf->height);
Mf->height-= 8; Add
return 0;
}



In addition, the RK_CAMERA_CIFIRQ () function has a check on if (reg_lastline! = pcdev->host_height), so the judgment here is removed:


pcdev->irqinfo.cifirq_idx++;
-if ((reg_lastline! = pcdev->host_height)/*| | (Reg_lastpix! = pcdev->host_width) */) {
-Pcdev->irqinfo.cifirq_abnormal_idx = pcdev->irqinfo.cifirq_idx;
-Rkcamera_dg2 ("Cif irq-%ld is error,%dx%d! =%dx%d\n", Pcdev->irqinfo.cifirq_abnormal_idx,
-Reg_lastpix,reg_lastline,pcdev->host_width,pcdev->host_height);
+ if (0) {//((Reg_lastline! = pcdev->host_height)/*| | (Reg_lastpix! = pcdev->host_width) */) {
+//pcdev->irqinfo.cifirq_abnormal_idx = pcdev->irqinfo.cifirq_idx;
+//RKCAMERA_DG2 ("Cif irq-%ld is error,%dx%d! =%dx%d\n", Pcdev->irqinfo.cifirq_abnormal_idx,
+//Reg_lastpix,reg_lastline,pcdev->host_width,pcdev->host_height);


2):
This changes whether the preview or the size of the photo taken less than 8 lines, preview (8 lines are not obvious) and the photo of the picture may have a green bar at the bottom;
Preview is likely not to see the green bar, because the preview picture is 4:3 (800x600) and the LCD screen is not 4:3, so take to show the composition, there is do cropping zoom;
And the photo will be able to see the green Bar (1600x1200),
Workaround:
In the photo function captureencprocesspicture (), force RGA scaling, but the input to RGA is the actual value of the source: frame->frame_height-16 (actually minus 8, but the RGA requires 16 alignment);
Git diff
Diff--git A/camerahal/appmsgnotifier.cpp B/camerahal/appmsgnotifier.cpp
Index EB96FFF: 686d95f 100755
---a/camerahal/appmsgnotifier.cpp
+ + B/camerahal/appmsgnotifier.cpp
@@ -1035,15 +1035,16 @@ -1035,15 appmsgnotifier::captureencprocesspicture (framinfo_s* frame) {
/*[email protected]: v0.4.7*/
BOOL rotat_180 = false; Used by IPP
FRAME-&GT;PHY_ADDR =-1, just for ISP Soc camera used Iommu,so ugly ...
-if ((frame->frame_fmt = = v4l2_pix_fmt_nv12) && ((frame->frame_width! = MPICTUREINFO.W) | | (Frame->frame_height! = mPictureInfo.h) | | (Frame->zoom_value! = 100) | | Frame->phy
-output_phy_addr = rawbuf_phy;
+//if ((frame->frame_fmt = = v4l2_pix_fmt_nv12) && ((frame->frame_width! = MPICTUREINFO.W) | | (Frame->frame_height! = mPictureInfo.h) | | (Frame->zoom_value! = 100) | | Frame->p
+ if (1) {
+ output_phy_addr = rawbuf_phy;
OUTPUT_VIR_ADDR = Rawbuf_vir;
#if 0
Arm_camera_yuv420_scale_arm (V4L2_PIX_FMT_NV12, V4L2_PIX_FMT_NV12, (char*) (FRAME-&GT;VIR_ADDR),
(char*) Rawbuf_vir,frame->frame_width, Frame->frame_height,
Jpeg_w, Jpeg_h,false,frame->zoom_value);
#else
-Rga_nv12_scale_crop (Frame->frame_width, Frame->frame_height,
+ Rga_nv12_scale_crop_cap (frame->frame_width, frame->frame_height-16,
(char*) (FRAME-&GT;VIR_ADDR), (short int *) Rawbuf_vir,
Jpeg_w,jpeg_w,jpeg_h,frame->zoom_value,false,!mis_verifier,false);
#endif


3):
This appears the result of the photo: Green bar Above the picture, add the following changes, RGA source virtual Gaoyao to the actual, such as (1600x1200) picture, the actual is 1200-8, here Rga_Request.src.vir_h or 1200;

CROPW = Src_width;
Croph = Src_height; Src_height is frame->frame_height-16;
Rga_Request.src.act_w = CROPW;
Rga_Request.src.act_h = Croph;
In this way, the cropping and zooming process from source 1600x (1200-8) to 1600x1200 is RGA.


Diff--git A/camerahal/camerahalutil.cpp B/camerahal/camerahalutil.cpp
Index F73c7e8: a174156 100755
---a/camerahal/camerahalutil.cpp
+ + B/camerahal/camerahalutil.cpp
@@ -450,7 +450,7 @@ -450,7 "C" int rga_nv12_scale_crop (int src_width, int src_height, char *src, Sho
RGA_REQUEST.SRC.UV_ADDR = (int) PsY;
Rga_Request.src.v_addr = 0;
Rga_Request.src.vir_w = Src_width;
-Rga_Request.src.vir_h = Src_height;
+ Rga_Request.src.vir_h = src_height+16;
Rga_Request.src.format = rk_format_ycbcr_420_sp;
Rga_Request.src.act_w = CROPW;
Rga_Request.src.act_h = Croph;




4)
But this rga_nv12_scale_crop () is not only used in photography, zoom and other occasions may be used, so there is a separate add to the RGA function for taking pictures:
2) Medium: Rga_nv12_scale_crop ()
Change to:
Rga_nv12_scale_crop_cap ()
3) in:
Rga_nv12_scale_crop () change back to add rga_nv12_scale_crop_cap () function; the difference is:
-Rga_Request.src.vir_h = Src_height;
+ Rga_Request.src.vir_h = src_height+16;

Add statement in CameraHal.h:
Diff--git A/camerahal/camerahal.h B/camerahal/camerahal.h
Index f1e8e8c: 505f22e 100755
---a/camerahal/camerahal.h
+ + b/camerahal/camerahal.h
@@ -118,6 +118,7 @@ -118,6 "C" int cameraformatconvert (int v4l2_fmt_src, int v4l2_fmt_dst, const CHA
BOOL mirror);

extern "C" int rga_nv12_scale_crop (int src_width, int src_height, char *src, short int *dst, int dstbuf_width,int Dst_widt H,int dst_height,int Zoom_val,bool Mirror,bool Isneedc
+extern "C" int rga_nv12_scale_crop_cap (int src_width, int src_height, char *src, short int *dst, int dstbuf_width,int DST _width,int dst_height,int Zoom_val,bool Mirror,bool IsN

extern rk_cam_info_t Gcaminfos[cameras_support_max];







About rk3066&rk3188 BOX 4.4.2 SDK, external USB camera, pixel set to 5 million, the lower right corner of the picture appears small rectangular color block.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.