Greg Hackmann | 210a69b | 2013-07-09 13:07:26 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2013 Google, Inc. |
| 3 | * |
| 4 | * This software is licensed under the terms of the GNU General Public |
| 5 | * License version 2, as published by the Free Software Foundation, and |
| 6 | * may be copied, distributed, and modified under those terms. |
| 7 | * |
| 8 | * This program is distributed in the hope that it will be useful, |
| 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 11 | * GNU General Public License for more details. |
| 12 | * |
| 13 | */ |
| 14 | |
| 15 | #ifndef _VIDEO_ADF_FBDEV_H_ |
| 16 | #define _VIDEO_ADF_FBDEV_H_ |
| 17 | |
| 18 | #include <linux/fb.h> |
Greg Hackmann | e25142e | 2014-03-24 16:45:43 -0700 | [diff] [blame] | 19 | #include <linux/mutex.h> |
Greg Hackmann | 210a69b | 2013-07-09 13:07:26 -0700 | [diff] [blame] | 20 | #include <video/adf.h> |
| 21 | |
| 22 | struct adf_fbdev { |
| 23 | struct adf_interface *intf; |
| 24 | struct adf_overlay_engine *eng; |
| 25 | struct fb_info *info; |
| 26 | u32 pseudo_palette[16]; |
| 27 | |
Greg Hackmann | e25142e | 2014-03-24 16:45:43 -0700 | [diff] [blame] | 28 | unsigned int refcount; |
| 29 | struct mutex refcount_lock; |
Greg Hackmann | 210a69b | 2013-07-09 13:07:26 -0700 | [diff] [blame] | 30 | |
| 31 | struct dma_buf *dma_buf; |
| 32 | u32 offset; |
| 33 | u32 pitch; |
| 34 | void *vaddr; |
| 35 | u32 format; |
| 36 | |
| 37 | u16 default_xres_virtual; |
| 38 | u16 default_yres_virtual; |
| 39 | u32 default_format; |
| 40 | }; |
| 41 | |
Greg Hackmann | 842a5f9 | 2014-04-29 11:18:45 -0700 | [diff] [blame] | 42 | #if IS_ENABLED(CONFIG_ADF_FBDEV) |
Greg Hackmann | 210a69b | 2013-07-09 13:07:26 -0700 | [diff] [blame] | 43 | void adf_modeinfo_to_fb_videomode(const struct drm_mode_modeinfo *mode, |
| 44 | struct fb_videomode *vmode); |
| 45 | void adf_modeinfo_from_fb_videomode(const struct fb_videomode *vmode, |
| 46 | struct drm_mode_modeinfo *mode); |
| 47 | |
| 48 | int adf_fbdev_init(struct adf_fbdev *fbdev, struct adf_interface *interface, |
| 49 | struct adf_overlay_engine *eng, |
| 50 | u16 xres_virtual, u16 yres_virtual, u32 format, |
| 51 | struct fb_ops *fbops, const char *fmt, ...); |
| 52 | void adf_fbdev_destroy(struct adf_fbdev *fbdev); |
| 53 | |
| 54 | int adf_fbdev_open(struct fb_info *info, int user); |
| 55 | int adf_fbdev_release(struct fb_info *info, int user); |
| 56 | int adf_fbdev_check_var(struct fb_var_screeninfo *var, struct fb_info *info); |
| 57 | int adf_fbdev_set_par(struct fb_info *info); |
| 58 | int adf_fbdev_blank(int blank, struct fb_info *info); |
| 59 | int adf_fbdev_pan_display(struct fb_var_screeninfo *var, struct fb_info *info); |
| 60 | int adf_fbdev_mmap(struct fb_info *info, struct vm_area_struct *vma); |
Greg Hackmann | 842a5f9 | 2014-04-29 11:18:45 -0700 | [diff] [blame] | 61 | #else |
| 62 | static inline void adf_modeinfo_to_fb_videomode(const struct drm_mode_modeinfo *mode, |
| 63 | struct fb_videomode *vmode) |
| 64 | { |
| 65 | WARN_ONCE(1, "%s: CONFIG_ADF_FBDEV is disabled\n", __func__); |
| 66 | } |
| 67 | |
| 68 | static inline void adf_modeinfo_from_fb_videomode(const struct fb_videomode *vmode, |
| 69 | struct drm_mode_modeinfo *mode) |
| 70 | { |
| 71 | WARN_ONCE(1, "%s: CONFIG_ADF_FBDEV is disabled\n", __func__); |
| 72 | } |
| 73 | |
| 74 | static inline int adf_fbdev_init(struct adf_fbdev *fbdev, |
| 75 | struct adf_interface *interface, |
| 76 | struct adf_overlay_engine *eng, |
| 77 | u16 xres_virtual, u16 yres_virtual, u32 format, |
| 78 | struct fb_ops *fbops, const char *fmt, ...) |
| 79 | { |
| 80 | return -ENODEV; |
| 81 | } |
| 82 | |
| 83 | static inline void adf_fbdev_destroy(struct adf_fbdev *fbdev) { } |
| 84 | |
| 85 | static inline int adf_fbdev_open(struct fb_info *info, int user) |
| 86 | { |
| 87 | return -ENODEV; |
| 88 | } |
| 89 | |
| 90 | static inline int adf_fbdev_release(struct fb_info *info, int user) |
| 91 | { |
| 92 | return -ENODEV; |
| 93 | } |
| 94 | |
| 95 | static inline int adf_fbdev_check_var(struct fb_var_screeninfo *var, |
| 96 | struct fb_info *info) |
| 97 | { |
| 98 | return -ENODEV; |
| 99 | } |
| 100 | |
| 101 | static inline int adf_fbdev_set_par(struct fb_info *info) |
| 102 | { |
| 103 | return -ENODEV; |
| 104 | } |
| 105 | |
| 106 | static inline int adf_fbdev_blank(int blank, struct fb_info *info) |
| 107 | { |
| 108 | return -ENODEV; |
| 109 | } |
| 110 | |
| 111 | static inline int adf_fbdev_pan_display(struct fb_var_screeninfo *var, |
| 112 | struct fb_info *info) |
| 113 | { |
| 114 | return -ENODEV; |
| 115 | } |
| 116 | |
| 117 | static inline int adf_fbdev_mmap(struct fb_info *info, |
| 118 | struct vm_area_struct *vma) |
| 119 | { |
| 120 | return -ENODEV; |
| 121 | } |
| 122 | #endif |
Greg Hackmann | 210a69b | 2013-07-09 13:07:26 -0700 | [diff] [blame] | 123 | |
| 124 | #endif /* _VIDEO_ADF_FBDEV_H_ */ |