This source file includes following definitions.
- drm_fb_cma_get_gem_obj
- drm_fb_cma_get_gem_addr
1
2
3
4
5
6
7
8
9
10
11
12 #include <drm/drm_fourcc.h>
13 #include <drm/drm_framebuffer.h>
14 #include <drm/drm_gem_cma_helper.h>
15 #include <drm/drm_gem_framebuffer_helper.h>
16 #include <drm/drm_plane.h>
17 #include <linux/module.h>
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38 struct drm_gem_cma_object *drm_fb_cma_get_gem_obj(struct drm_framebuffer *fb,
39 unsigned int plane)
40 {
41 struct drm_gem_object *gem;
42
43 gem = drm_gem_fb_get_obj(fb, plane);
44 if (!gem)
45 return NULL;
46
47 return to_drm_gem_cma_obj(gem);
48 }
49 EXPORT_SYMBOL_GPL(drm_fb_cma_get_gem_obj);
50
51
52
53
54
55
56
57
58
59
60
61
62 dma_addr_t drm_fb_cma_get_gem_addr(struct drm_framebuffer *fb,
63 struct drm_plane_state *state,
64 unsigned int plane)
65 {
66 struct drm_gem_cma_object *obj;
67 dma_addr_t paddr;
68 u8 h_div = 1, v_div = 1;
69 u32 block_w = drm_format_info_block_width(fb->format, plane);
70 u32 block_h = drm_format_info_block_height(fb->format, plane);
71 u32 block_size = fb->format->char_per_block[plane];
72 u32 sample_x;
73 u32 sample_y;
74 u32 block_start_y;
75 u32 num_hblocks;
76
77 obj = drm_fb_cma_get_gem_obj(fb, plane);
78 if (!obj)
79 return 0;
80
81 paddr = obj->paddr + fb->offsets[plane];
82
83 if (plane > 0) {
84 h_div = fb->format->hsub;
85 v_div = fb->format->vsub;
86 }
87
88 sample_x = (state->src_x >> 16) / h_div;
89 sample_y = (state->src_y >> 16) / v_div;
90 block_start_y = (sample_y / block_h) * block_h;
91 num_hblocks = sample_x / block_w;
92
93 paddr += fb->pitches[plane] * block_start_y;
94 paddr += block_size * num_hblocks;
95
96 return paddr;
97 }
98 EXPORT_SYMBOL_GPL(drm_fb_cma_get_gem_addr);