Lines Matching +full:y +full:- +full:offset

1 // SPDX-License-Identifier: GPL-2.0+
13 * packed_pixels_offset() - Get the offset of the block containing the pixel at coordinates x/y
17 * @y: The y coordinate of the wanted pixel in the buffer
19 * @offset: The returned offset inside the buffer of the block
21 * @rem_y: The returned Y coordinate of the requested pixel in the block
24 * pixels are not individually addressable. This function return 3 values: the offset of the
26 * For example, if the format is DRM_FORMAT_R1 and the requested coordinate is 13,5, the offset
32 static void packed_pixels_offset(const struct vkms_frame_info *frame_info, int x, int y, in packed_pixels_offset() argument
33 int plane_index, int *offset, int *rem_x, int *rem_y) in packed_pixels_offset() argument
35 struct drm_framebuffer *fb = frame_info->fb; in packed_pixels_offset()
36 const struct drm_format_info *format = frame_info->fb->format; in packed_pixels_offset()
37 /* Directly using x and y to multiply pitches and format->ccp is not sufficient because in packed_pixels_offset()
40 * Dividing x and y by the block size allows to extract the correct offset of the block in packed_pixels_offset()
45 int block_y = y / drm_format_info_block_height(format, plane_index); in packed_pixels_offset()
46 int block_pitch = fb->pitches[plane_index] * drm_format_info_block_height(format, in packed_pixels_offset()
49 *rem_y = y % drm_format_info_block_height(format, plane_index); in packed_pixels_offset()
50 *offset = fb->offsets[plane_index] + in packed_pixels_offset()
52 block_x * format->char_per_block[plane_index]; in packed_pixels_offset()
56 * packed_pixels_addr() - Get the pointer to the block containing the pixel at the given
61 * @y: The y (height) coordinate inside the plane
65 * @rem_y: The returned Y coordinate of the requested pixel in the block
73 int x, int y, int plane_index, u8 **addr, int *rem_x, in packed_pixels_addr() argument
76 int offset; in packed_pixels_addr() local
78 packed_pixels_offset(frame_info, x, y, plane_index, &offset, rem_x, rem_y); in packed_pixels_addr()
79 *addr = (u8 *)frame_info->map[0].vaddr + offset; in packed_pixels_addr()
83 * get_block_step_bytes() - Common helper to compute the correct step value between each pixel block
100 return fb->format->char_per_block[plane_index]; in get_block_step_bytes()
102 return -fb->format->char_per_block[plane_index]; in get_block_step_bytes()
104 return (int)fb->pitches[plane_index] * drm_format_info_block_width(fb->format, in get_block_step_bytes()
107 return -(int)fb->pitches[plane_index] * drm_format_info_block_width(fb->format, in get_block_step_bytes()
115 * packed_pixels_addr_1x1() - Get the pointer to the block containing the pixel at the given
120 * @y: The y (height) coordinate inside the plane
127 int x, int y, int plane_index, u8 **addr) in packed_pixels_addr_1x1() argument
129 int offset, rem_x, rem_y; in packed_pixels_addr_1x1() local
131 WARN_ONCE(drm_format_info_block_width(frame_info->fb->format, in packed_pixels_addr_1x1()
134 WARN_ONCE(drm_format_info_block_height(frame_info->fb->format, in packed_pixels_addr_1x1()
138 packed_pixels_offset(frame_info, x, y, plane_index, &offset, &rem_x, in packed_pixels_addr_1x1()
140 *addr = (u8 *)frame_info->map[0].vaddr + offset; in packed_pixels_addr_1x1()
155 * (2^16 - 1) / (2^8 - 1) division. Which, in this case, tries to get in argb_u16_from_u8888()
215 * [1]: https://lore.kernel.org/dri-devel/d258c8dc-78e9-4509-9037-a98f7f33b3a3@riseup.net/
225 packed_pixels_addr_1x1(plane->frame_info, x_start, y_start, 0, &src_pixels); in ARGB8888_read_line()
227 int step = get_block_step_bytes(plane->frame_info->fb, direction, 0); in ARGB8888_read_line()
244 packed_pixels_addr_1x1(plane->frame_info, x_start, y_start, 0, &src_pixels); in XRGB8888_read_line()
246 int step = get_block_step_bytes(plane->frame_info->fb, direction, 0); in XRGB8888_read_line()
263 packed_pixels_addr_1x1(plane->frame_info, x_start, y_start, 0, &src_pixels); in ARGB16161616_read_line()
265 int step = get_block_step_bytes(plane->frame_info->fb, direction, 0); in ARGB16161616_read_line()
282 packed_pixels_addr_1x1(plane->frame_info, x_start, y_start, 0, &src_pixels); in XRGB16161616_read_line()
284 int step = get_block_step_bytes(plane->frame_info->fb, direction, 0); in XRGB16161616_read_line()
301 packed_pixels_addr_1x1(plane->frame_info, x_start, y_start, 0, &src_pixels); in RGB565_read_line()
303 int step = get_block_step_bytes(plane->frame_info->fb, direction, 0); in RGB565_read_line()
325 * in little-endian. In the case of the ARGB8888 the memory is in argb_u16_to_ARGB8888()
333 out_pixel[3] = DIV_ROUND_CLOSEST(in_pixel->a, 257); in argb_u16_to_ARGB8888()
334 out_pixel[2] = DIV_ROUND_CLOSEST(in_pixel->r, 257); in argb_u16_to_ARGB8888()
335 out_pixel[1] = DIV_ROUND_CLOSEST(in_pixel->g, 257); in argb_u16_to_ARGB8888()
336 out_pixel[0] = DIV_ROUND_CLOSEST(in_pixel->b, 257); in argb_u16_to_ARGB8888()
342 out_pixel[2] = DIV_ROUND_CLOSEST(in_pixel->r, 257); in argb_u16_to_XRGB8888()
343 out_pixel[1] = DIV_ROUND_CLOSEST(in_pixel->g, 257); in argb_u16_to_XRGB8888()
344 out_pixel[0] = DIV_ROUND_CLOSEST(in_pixel->b, 257); in argb_u16_to_XRGB8888()
351 pixel[3] = cpu_to_le16(in_pixel->a); in argb_u16_to_ARGB16161616()
352 pixel[2] = cpu_to_le16(in_pixel->r); in argb_u16_to_ARGB16161616()
353 pixel[1] = cpu_to_le16(in_pixel->g); in argb_u16_to_ARGB16161616()
354 pixel[0] = cpu_to_le16(in_pixel->b); in argb_u16_to_ARGB16161616()
362 pixel[2] = cpu_to_le16(in_pixel->r); in argb_u16_to_XRGB16161616()
363 pixel[1] = cpu_to_le16(in_pixel->g); in argb_u16_to_XRGB16161616()
364 pixel[0] = cpu_to_le16(in_pixel->b); in argb_u16_to_XRGB16161616()
374 s64 fp_r = drm_int2fixp(in_pixel->r); in argb_u16_to_RGB565()
375 s64 fp_g = drm_int2fixp(in_pixel->g); in argb_u16_to_RGB565()
376 s64 fp_b = drm_int2fixp(in_pixel->b); in argb_u16_to_RGB565()
386 * vkms_writeback_row() - Generic loop for all supported writeback format. It is executed just
391 * @y: Row to write in the writeback buffer
394 const struct line_buffer *src_buffer, int y) in vkms_writeback_row() argument
396 struct vkms_frame_info *frame_info = &wb->wb_frame_info; in vkms_writeback_row()
397 int x_dst = frame_info->dst.x1; in vkms_writeback_row()
401 packed_pixels_addr(frame_info, x_dst, y, 0, &dst_pixels, &rem_x, &rem_y); in vkms_writeback_row()
402 struct pixel_argb_u16 *in_pixels = src_buffer->pixels; in vkms_writeback_row()
403 int x_limit = min_t(size_t, drm_rect_width(&frame_info->dst), src_buffer->n_pixels); in vkms_writeback_row()
405 for (size_t x = 0; x < x_limit; x++, dst_pixels += frame_info->fb->format->cpp[0]) in vkms_writeback_row()
406 wb->pixel_write(dst_pixels, &in_pixels[x]); in vkms_writeback_row()
410 * get_pixel_read_line_function() - Retrieve the correct read_line function for a specific
433 * - Be listed in vkms_formats in vkms_plane.c in get_pixel_read_line_function()
434 * - Have a pixel_read callback defined here in get_pixel_read_line_function()
443 * get_pixel_write_function() - Retrieve the correct write_pixel function for a specific format.
466 * - Be listed in vkms_wb_formats in vkms_writeback.c in get_pixel_write_function()
467 * - Have a pixel_write callback defined here in get_pixel_write_function()