/** *packed_pixels_offset()-Gettheoffsetoftheblockcontainingthepixelatcoordinatesx/y * *@frame_info:Buffermetadata *@x:Thexcoordinateofthewantedpixelinthebuffer *@y:Theycoordinateofthewantedpixelinthebuffer *@plane_index:Theindexoftheplanetouse *@offset:Thereturnedoffsetinsidethebufferoftheblock *@rem_x:ThereturnedXcoordinateoftherequestedpixelintheblock *@rem_y:ThereturnedYcoordinateoftherequestedpixelintheblock * *Assomepixelformatsstoremultiplepixelsinablock(DRM_FORMAT_R*forexample),some *pixelsarenotindividuallyaddressable.Thisfunctionreturn3values:theoffsetofthe *wholeblock,andthecoordinateoftherequestedpixelinsidethisblock. *Forexample,iftheformatisDRM_FORMAT_R1andtherequestedcoordinateis13,5,theoffset *willpointtothebyte5*pitches+13/8(secondbyteofthe5thline),andtherem_x/rem_y *coordinateswillbe(13%8,5%1)=(5,0) * *Withthisfunction,thecallerjusthavetoextractthecorrectpixelfromtheblock.
*/ staticvoid packed_pixels_offset(conststruct vkms_frame_info *frame_info, int x, int y, int plane_index, int *offset, int *rem_x, int *rem_y)
{ struct drm_framebuffer *fb = frame_info->fb; conststruct drm_format_info *format = frame_info->fb->format; /* Directly using x and y to multiply pitches and format->ccp is not sufficient because *insomeformatsablockcanrepresentmultiplepixels. * *Dividingxandybytheblocksizeallowstoextractthecorrectoffsetoftheblock *containingthepixel.
*/
int block_x = x / drm_format_info_block_width(format, plane_index); int block_y = y / drm_format_info_block_height(format, plane_index); int block_pitch = fb->pitches[plane_index] * drm_format_info_block_height(format,
plane_index);
*rem_x = x % drm_format_info_block_width(format, plane_index);
*rem_y = y % drm_format_info_block_height(format, plane_index);
*offset = fb->offsets[plane_index] +
block_y * block_pitch +
block_x * format->char_per_block[plane_index];
}
/** *packed_pixels_addr()-Getthepointertotheblockcontainingthepixelatthegiven *coordinates * *@frame_info:Buffermetadata *@x:Thex(width)coordinateinsidetheplane *@y:They(height)coordinateinsidetheplane *@plane_index:Theindexoftheplane *@addr:Thereturnedpointer *@rem_x:ThereturnedXcoordinateoftherequestedpixelintheblock *@rem_y:ThereturnedYcoordinateoftherequestedpixelintheblock * *Takestheinformationstoredintheframe_info,apairofcoordinates,andreturnstheaddress *oftheblockcontainingthispixelandthepixelpositioninsidethisblock. * *See@packed_pixels_offsetfordetailsaboutrem_x/rem_ybehavior.
*/ staticvoid packed_pixels_addr(conststruct vkms_frame_info *frame_info, int x, int y, int plane_index, u8 **addr, int *rem_x, int *rem_y)
{ int offset;
/** *get_block_step_bytes()-Commonhelpertocomputethecorrectstepvaluebetweeneachpixelblock *toreadinacertaindirection. * *@fb:Framebuffertoiteron *@direction:Directionofthereading *@plane_index:Planetogetthestepfrom * *Asthereturnedcountisthenumberofbytesbetweentwoconsecutiveblocksinadirection, *thecallermayhavetoreadmultiplepixelsbeforeusingthenextone(forexample,toreadfrom *lefttorightinaDRM_FORMAT_R1plane,eachblockcontains8pixels,sothestepmustbeused *onlyevery8pixels).
*/ staticint get_block_step_bytes(struct drm_framebuffer *fb, enum pixel_read_direction direction, int plane_index)
{ switch (direction) { case READ_LEFT_TO_RIGHT: return fb->format->char_per_block[plane_index]; case READ_RIGHT_TO_LEFT: return -fb->format->char_per_block[plane_index]; case READ_TOP_TO_BOTTOM: return (int)fb->pitches[plane_index] * drm_format_info_block_width(fb->format,
plane_index); case READ_BOTTOM_TO_TOP: return -(int)fb->pitches[plane_index] * drm_format_info_block_width(fb->format,
plane_index);
}
return0;
}
/** *packed_pixels_addr_1x1()-Getthepointertotheblockcontainingthepixelatthegiven *coordinates * *@frame_info:Buffermetadata *@x:Thex(width)coordinateinsidetheplane *@y:They(height)coordinateinsidetheplane *@plane_index:Theindexoftheplane *@addr:Thereturnedpointer * *Thisfunctioncanonlybeusedwithformatwhereblock_h==block_w==1.
*/ staticvoid packed_pixels_addr_1x1(conststruct vkms_frame_info *frame_info, int x, int y, int plane_index, u8 **addr)
{ int offset, rem_x, rem_y;
WARN_ONCE(drm_format_info_block_width(frame_info->fb->format,
plane_index) != 1, "%s() only support formats with block_w == 1", __func__);
WARN_ONCE(drm_format_info_block_height(frame_info->fb->format,
plane_index) != 1, "%s() only support formats with block_h == 1", __func__);
u16 r = drm_fixp2int(drm_fixp_div(fp_r, fp_rb_ratio));
u16 g = drm_fixp2int(drm_fixp_div(fp_g, fp_g_ratio));
u16 b = drm_fixp2int(drm_fixp_div(fp_b, fp_rb_ratio));
packed_pixels_addr(frame_info, x_dst, y, 0, &dst_pixels, &rem_x, &rem_y); struct pixel_argb_u16 *in_pixels = src_buffer->pixels; int x_limit = min_t(size_t, drm_rect_width(&frame_info->dst), src_buffer->n_pixels);
for (size_t x = 0; x < x_limit; x++, dst_pixels += frame_info->fb->format->cpp[0])
wb->pixel_write(dst_pixels, &in_pixels[x]);
}
/** *get_pixel_read_line_function()-Retrievethecorrectread_linefunctionforaspecific *format.ThereturnedpointerisNULLforunsupportedpixelformats.Thecallermustensurethat *thepointerisvalidbeforeusingitinavkms_plane_state. * *@format:DRM_FORMAT_*valueforwhichtoobtainaconversionfunction(see[drm_fourcc.h])
*/
pixel_read_line_t get_pixel_read_line_function(u32 format)
{ switch (format) { case DRM_FORMAT_ARGB8888: return &ARGB8888_read_line; case DRM_FORMAT_XRGB8888: return &XRGB8888_read_line; case DRM_FORMAT_ABGR8888: return &ABGR8888_read_line; case DRM_FORMAT_ARGB16161616: return &ARGB16161616_read_line; case DRM_FORMAT_XRGB16161616: return &XRGB16161616_read_line; case DRM_FORMAT_RGB565: return &RGB565_read_line; case DRM_FORMAT_NV12: case DRM_FORMAT_NV16: case DRM_FORMAT_NV24: case DRM_FORMAT_NV21: case DRM_FORMAT_NV61: case DRM_FORMAT_NV42: return &semi_planar_yuv_read_line; case DRM_FORMAT_YUV420: case DRM_FORMAT_YUV422: case DRM_FORMAT_YUV444: case DRM_FORMAT_YVU420: case DRM_FORMAT_YVU422: case DRM_FORMAT_YVU444: return &planar_yuv_read_line; case DRM_FORMAT_R1: return &R1_read_line; case DRM_FORMAT_R2: return &R2_read_line; case DRM_FORMAT_R4: return &R4_read_line; case DRM_FORMAT_R8: return &R8_read_line; default: /* *Thisisabuginvkms_plane_atomic_check().Allthesupported *formatmust: *-Belistedinvkms_formatsinvkms_plane.c *-Haveapixel_readcallbackdefinedhere
*/
pr_err("Pixel format %p4cc is not supported by VKMS planes. This is a kernel bug, atomic check must forbid this configuration.\n",
&format);
BUG();
}
}
switch (range) { case DRM_COLOR_YCBCR_LIMITED_RANGE:
limited_range = true; break; case DRM_COLOR_YCBCR_FULL_RANGE:
limited_range = false; break; case DRM_COLOR_RANGE_MAX:
limited_range = false;
WARN_ONCE(true, "The requested range is not supported."); break;
}
switch (encoding) { case DRM_COLOR_YCBCR_BT601:
matrix_to_copy = limited_range ? &yuv_bt601_limited :
&yuv_bt601_full; break; case DRM_COLOR_YCBCR_BT709:
matrix_to_copy = limited_range ? &yuv_bt709_limited :
&yuv_bt709_full; break; case DRM_COLOR_YCBCR_BT2020:
matrix_to_copy = limited_range ? &yuv_bt2020_limited :
&yuv_bt2020_full; break; case DRM_COLOR_ENCODING_MAX:
matrix_to_copy = &no_operation;
WARN_ONCE(true, "The requested encoding is not supported."); break;
}
switch (format) { case DRM_FORMAT_YVU420: case DRM_FORMAT_YVU422: case DRM_FORMAT_YVU444: case DRM_FORMAT_NV21: case DRM_FORMAT_NV61: case DRM_FORMAT_NV42:
swap_uv_columns(matrix); break; default: break;
}
}
EXPORT_SYMBOL(get_conversion_matrix_to_argb_u16);
/** *get_pixel_write_function()-Retrievethecorrectwrite_pixelfunctionforaspecificformat. *ThereturnedpointerisNULLforunsupportedpixelformats.Thecallermustensurethatthe *pointerisvalidbeforeusingitinavkms_writeback_job. * *@format:DRM_FORMAT_*valueforwhichtoobtainaconversionfunction(see[drm_fourcc.h])
*/
pixel_write_t get_pixel_write_function(u32 format)
{ switch (format) { case DRM_FORMAT_ARGB8888: return &argb_u16_to_ARGB8888; case DRM_FORMAT_XRGB8888: return &argb_u16_to_XRGB8888; case DRM_FORMAT_ABGR8888: return &argb_u16_to_ABGR8888; case DRM_FORMAT_ARGB16161616: return &argb_u16_to_ARGB16161616; case DRM_FORMAT_XRGB16161616: return &argb_u16_to_XRGB16161616; case DRM_FORMAT_RGB565: return &argb_u16_to_RGB565; default: /* *Thisisabuginvkms_writeback_atomic_check.Allthesupported *formatmust: *-Belistedinvkms_wb_formatsinvkms_writeback.c *-Haveapixel_writecallbackdefinedhere
*/
pr_err("Pixel format %p4cc is not supported by VKMS writeback. This is a kernel bug, atomic check must forbid this configuration.\n",
&format);
BUG();
}
}
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.19 Sekunden
(vorverarbeitet am 2026-09-28)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.