blob: f198dd9668d81ad008df511aef4730fde288b7d1 [file] [log] [blame]
Gurchetan Singh2e786ad2016-08-24 18:31:23 -07001/*
2 * Copyright 2016 The Chromium OS Authors. All rights reserved.
3 * Use of this source code is governed by a BSD-style license that can be
4 * found in the LICENSE file.
5 */
6
7#ifndef CROS_GRALLOC_HELPERS_H
8#define CROS_GRALLOC_HELPERS_H
9
Gurchetan Singhc67f9e42016-11-28 15:25:26 -080010#include "../drv.h"
Gurchetan Singh2e786ad2016-08-24 18:31:23 -070011#include "cros_gralloc_handle.h"
Gurchetan Singhd6b8b032017-05-31 14:31:31 -070012#include "cros_gralloc_types.h"
Gurchetan Singh2e786ad2016-08-24 18:31:23 -070013
Gurchetan Singh2e786ad2016-08-24 18:31:23 -070014#include <system/graphics.h>
Gurchetan Singhd6b8b032017-05-31 14:31:31 -070015#include <system/window.h>
Gurchetan Singh2e786ad2016-08-24 18:31:23 -070016
Gurchetan Singhb7538e22017-03-20 14:45:39 -070017constexpr uint32_t cros_gralloc_magic = 0xABCDDCBA;
Gurchetan Singh989873c2017-05-26 10:04:29 -070018constexpr uint32_t handle_data_size =
19 ((sizeof(struct cros_gralloc_handle) - offsetof(cros_gralloc_handle, fds[0])) / sizeof(int));
Gurchetan Singh2e786ad2016-08-24 18:31:23 -070020
Gurchetan Singhd6b8b032017-05-31 14:31:31 -070021uint32_t cros_gralloc_convert_format(int32_t format);
Gurchetan Singh2e786ad2016-08-24 18:31:23 -070022
Gurchetan Singhd6b8b032017-05-31 14:31:31 -070023cros_gralloc_handle_t cros_gralloc_convert_handle(buffer_handle_t handle);
Gurchetan Singh2e786ad2016-08-24 18:31:23 -070024
Gurchetan Singh1b1d56a2017-03-10 16:25:23 -080025__attribute__((format(printf, 4, 5))) void cros_gralloc_log(const char *prefix, const char *file,
26 int line, const char *format, ...);
Gurchetan Singh2e786ad2016-08-24 18:31:23 -070027
Gurchetan Singh1b1d56a2017-03-10 16:25:23 -080028#define cros_gralloc_error(...) \
29 do { \
30 cros_gralloc_log("CROS_GRALLOC_ERROR", __FILE__, __LINE__, __VA_ARGS__); \
Gurchetan Singh2e786ad2016-08-24 18:31:23 -070031 } while (0)
32
33#endif