📄 mem.c
字号:
/* * $QNXLicenseC: * Copyright 2007, QNX Software Systems. * * Licensed under the Apache License, Version 2.0 (the "License"). You * may not reproduce, modify or distribute this software except in * compliance with the License. You may obtain a copy of the License * at: http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" basis, * WITHOUT WARRANTIES OF ANY KIND, either express or implied. * * This file may contain contributions from others, either as * contributors under the License or as licensors under other terms. * Please review this entire file for other proprietary rights or license * notices, as well as the QNX Development Suite License Guide at * http://licensing.qnx.com/license-guide/ for other information. * $ */#include <stdlib.h>#include "imx21.h"intimx21_mem_init(disp_adapter_t *adp, char *optstring){ return 0;}voidimx21_mem_fini(disp_adapter_t *adp){}intimx21_mem_reset(disp_adapter_t *adp, disp_surface_t *surf){ return 0;}disp_surface_t *imx21_alloc_surface(disp_adapter_t *adp, int width, int height, unsigned format, unsigned flags, unsigned user_flags){ disp_surface_t *surf; int stride; void *vidptr; unsigned mapflags = 0; flags &= DISP_SURFACE_CAPS_MASK; stride = width * DISP_BYTES_PER_PIXEL(format); if (flags & DISP_SURFACE_DISPLAYABLE) { /* * Each line must start on a four-byte boundary, * for LCD controller */ if (stride & 3) stride = (stride & ~3) + 4; } if (flags & ~(DISP_SURFACE_DISPLAYABLE | DISP_SURFACE_CPU_LINEAR_READABLE | DISP_SURFACE_CPU_LINEAR_WRITEABLE | DISP_SURFACE_PHYS_CONTIG | DISP_SURFACE_PAGE_ALIGNED)) { return 0; } if ((surf = calloc(1, sizeof(*surf))) == 0) { return 0; } if (flags & (DISP_SURFACE_PHYS_CONTIG | DISP_SURFACE_DISPLAYABLE)) mapflags |= DISP_MAP_PHYS; if ((vidptr = disp_getmem(height * stride, PROT_READ|PROT_WRITE|PROT_NOCACHE, mapflags)) == NULL) { free(surf); return 0; } surf->pixel_format = format; surf->vidptr = vidptr; surf->offset = surf->paddr = disp_phys_addr(vidptr); surf->stride = stride; surf->flags = flags | DISP_SURFACE_CPU_LINEAR_READABLE | DISP_SURFACE_CPU_LINEAR_WRITEABLE; surf->width = width; surf->height = height; return surf;}intimx21_free_surface(disp_adapter_t *adp, disp_surface_t *surf){ /* * Free offscreen surface */ disp_freemem(surf->vidptr, surf->stride*surf->height); free(surf); return 0;}unsigned longimx21_mem_avail(disp_adapter_t *adp, unsigned flags){ return 0;}intdevg_get_memfuncs(disp_adapter_t *adp, disp_memfuncs_t *funcs, int tabsize){ DISP_ADD_FUNC(disp_memfuncs_t, funcs, init, imx21_mem_init, tabsize); DISP_ADD_FUNC(disp_memfuncs_t, funcs, fini, imx21_mem_fini, tabsize); DISP_ADD_FUNC(disp_memfuncs_t, funcs, module_info, imx21_module_info, tabsize); DISP_ADD_FUNC(disp_memfuncs_t, funcs, reset, imx21_mem_reset, tabsize); DISP_ADD_FUNC(disp_memfuncs_t, funcs, alloc_surface, imx21_alloc_surface, tabsize); DISP_ADD_FUNC(disp_memfuncs_t, funcs, free_surface, imx21_free_surface, tabsize); DISP_ADD_FUNC(disp_memfuncs_t, funcs, mem_avail, imx21_mem_avail, tabsize); return 0;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -