~thopiekar/arm-mali/libvdpau-sunxi

« back to all changes in this revision

Viewing changes to sunxi_disp1_5.c

  • Committer: Andreas Baierl
  • Author(s): Jens Kuske
  • Date: 2016-02-24 18:03:58 UTC
  • Revision ID: git-v1:4e27c99dfde3c04b79b9861a0deff942be523410
Add OSD support for A33/A80

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
 
 * Copyright (c) 2015 Jens Kuske <jenskuske@gmail.com>
 
2
 * Copyright (c) 2015-2016 Jens Kuske <jenskuske@gmail.com>
3
3
 *
4
4
 * This library is free software; you can redistribute it and/or
5
5
 * modify it under the terms of the GNU Lesser General Public
33
33
 
34
34
        int fd;
35
35
        disp_layer_info video_info;
36
 
        int layer_id;
 
36
        int video_layer;
 
37
        disp_layer_info osd_info;
 
38
        int osd_layer;
37
39
        unsigned int screen_width;
38
40
};
39
41
 
51
53
        if (disp->fd == -1)
52
54
                goto err_open;
53
55
 
54
 
        unsigned long args[3] = { 0, 0, (unsigned long) &disp->video_info };
 
56
        unsigned long args[4] = { 0, 0, (unsigned long) &disp->video_info };
55
57
 
56
 
        disp->layer_id = 1;
57
 
        args[1] = disp->layer_id;
 
58
        disp->video_layer = 1;
 
59
        args[1] = disp->video_layer;
58
60
 
59
61
        disp->video_info.mode = DISP_LAYER_WORK_MODE_SCALER;
60
62
        disp->video_info.alpha_mode = 1;
70
72
        if (ioctl(disp->fd, DISP_CMD_LAYER_SET_INFO, args))
71
73
                goto err_video_layer;
72
74
 
 
75
        if (osd_enabled)
 
76
        {
 
77
                disp->osd_layer = 2;
 
78
                args[1] = disp->osd_layer;
 
79
                args[2] = (unsigned long)&disp->osd_info;
 
80
 
 
81
                disp->osd_info.mode = DISP_LAYER_WORK_MODE_NORMAL;
 
82
                disp->osd_info.alpha_mode = 0;
 
83
                disp->osd_info.alpha_value = 255;
 
84
                disp->osd_info.pipe = 0;
 
85
                disp->osd_info.ck_enable = 0;
 
86
                disp->osd_info.b_trd_out = 0;
 
87
                disp->osd_info.zorder = 2;
 
88
 
 
89
                if (ioctl(disp->fd, DISP_CMD_LAYER_DISABLE, args))
 
90
                        goto err_video_layer;
 
91
 
 
92
                if (ioctl(disp->fd, DISP_CMD_LAYER_SET_INFO, args))
 
93
                        goto err_video_layer;
 
94
        }
 
95
 
73
96
        disp->screen_width = ioctl(disp->fd, DISP_CMD_GET_SCN_WIDTH, args);
74
97
 
75
98
        disp->pub.close = sunxi_disp1_5_close;
91
114
{
92
115
        struct sunxi_disp1_5_private *disp = (struct sunxi_disp1_5_private *)sunxi_disp;
93
116
 
94
 
        unsigned long args[2] = { 0, disp->layer_id };
 
117
        unsigned long args[4] = { 0, disp->video_layer };
95
118
 
96
119
        ioctl(disp->fd, DISP_CMD_LAYER_DISABLE, args);
97
120
 
 
121
        if (disp->osd_layer)
 
122
        {
 
123
                args[1] = disp->osd_layer;
 
124
                ioctl(disp->fd, DISP_CMD_LAYER_DISABLE, args);
 
125
        }
 
126
 
98
127
        close(disp->fd);
99
128
        free(sunxi_disp);
100
129
}
136
165
                src.width -= src_clip;
137
166
        }
138
167
 
139
 
        unsigned long args[3] = { 0, disp->layer_id, (unsigned long)(&disp->video_info) };
 
168
        unsigned long args[4] = { 0, disp->video_layer, (unsigned long)(&disp->video_info) };
140
169
        switch (surface->vs->source_format)
141
170
        {
142
171
        case VDP_YCBCR_FORMAT_YUYV:
180
209
{
181
210
        struct sunxi_disp1_5_private *disp = (struct sunxi_disp1_5_private *)sunxi_disp;
182
211
 
183
 
        unsigned long args[2] = { 0, disp->layer_id };
 
212
        unsigned long args[4] = { 0, disp->video_layer };
184
213
 
185
214
        ioctl(disp->fd, DISP_CMD_LAYER_DISABLE, args);
186
215
}
187
216
 
188
217
static int sunxi_disp1_5_set_osd_layer(struct sunxi_disp *sunxi_disp, int x, int y, int width, int height, output_surface_ctx_t *surface)
189
218
{
190
 
        return -ENOTSUP;
 
219
        struct sunxi_disp1_5_private *disp = (struct sunxi_disp1_5_private *)sunxi_disp;
 
220
 
 
221
        unsigned long args[4] = { 0, disp->osd_layer, (unsigned long)(&disp->osd_info) };
 
222
 
 
223
        disp_window src = { .x = surface->rgba.dirty.x0, .y = surface->rgba.dirty.y0,
 
224
                          .width = surface->rgba.dirty.x1 - surface->rgba.dirty.x0,
 
225
                          .height = surface->rgba.dirty.y1 - surface->rgba.dirty.y0 };
 
226
        disp_window scn = { .x = x + surface->rgba.dirty.x0, .y = y + surface->rgba.dirty.y0,
 
227
                          .width = min_nz(width, surface->rgba.dirty.x1) - surface->rgba.dirty.x0,
 
228
                          .height = min_nz(height, surface->rgba.dirty.y1) - surface->rgba.dirty.y0 };
 
229
 
 
230
        switch (surface->rgba.format)
 
231
        {
 
232
        case VDP_RGBA_FORMAT_R8G8B8A8:
 
233
                disp->osd_info.fb.format = DISP_FORMAT_ABGR_8888;
 
234
                break;
 
235
        case VDP_RGBA_FORMAT_B8G8R8A8:
 
236
        default:
 
237
                disp->osd_info.fb.format = DISP_FORMAT_ARGB_8888;
 
238
                break;
 
239
        }
 
240
 
 
241
        disp->osd_info.fb.addr[0] = cedrus_mem_get_phys_addr(surface->rgba.data);
 
242
        disp->osd_info.fb.size.width = surface->rgba.width;
 
243
        disp->osd_info.fb.size.height = surface->rgba.height;
 
244
        disp->osd_info.fb.src_win = src;
 
245
        disp->osd_info.screen_win = scn;
 
246
 
 
247
        if (ioctl(disp->fd, DISP_CMD_LAYER_ENABLE, args))
 
248
                return -EINVAL;
 
249
 
 
250
        if (ioctl(disp->fd, DISP_CMD_LAYER_SET_INFO, args))
 
251
                return -EINVAL;
 
252
 
 
253
        return 0;
191
254
}
192
255
 
193
256
static void sunxi_disp1_5_close_osd_layer(struct sunxi_disp *sunxi_disp)
194
257
{
195
 
        return;
 
258
        struct sunxi_disp1_5_private *disp = (struct sunxi_disp1_5_private *)sunxi_disp;
 
259
 
 
260
        unsigned long args[4] = { 0, disp->osd_layer };
 
261
 
 
262
        ioctl(disp->fd, DISP_CMD_LAYER_DISABLE, args);
196
263
}