linux/include/linux/fb.h

/* SPDX-License-Identifier: GPL-2.0 */
#ifndef _LINUX_FB_H
#define _LINUX_FB_H

#include <uapi/linux/fb.h>

#define FBIO_CURSOR

#include <linux/mutex.h>
#include <linux/printk.h>
#include <linux/refcount.h>
#include <linux/types.h>
#include <linux/workqueue.h>

#include <asm/video.h>

struct backlight_device;
struct device;
struct device_node;
struct fb_info;
struct file;
struct i2c_adapter;
struct inode;
struct module;
struct notifier_block;
struct page;
struct videomode;
struct vm_area_struct;

/* Definitions below are used in the parsed monitor specs */
#define FB_DPMS_ACTIVE_OFF
#define FB_DPMS_SUSPEND
#define FB_DPMS_STANDBY

#define FB_DISP_DDI
#define FB_DISP_ANA_700_300
#define FB_DISP_ANA_714_286
#define FB_DISP_ANA_1000_400
#define FB_DISP_ANA_700_000

#define FB_DISP_MONO
#define FB_DISP_RGB
#define FB_DISP_MULTI
#define FB_DISP_UNKNOWN

#define FB_SIGNAL_NONE
#define FB_SIGNAL_BLANK_BLANK
#define FB_SIGNAL_SEPARATE
#define FB_SIGNAL_COMPOSITE
#define FB_SIGNAL_SYNC_ON_GREEN
#define FB_SIGNAL_SERRATION_ON

#define FB_MISC_PRIM_COLOR
#define FB_MISC_1ST_DETAIL
#define FB_MISC_HDMI
struct fb_chroma {};

struct fb_monspecs {};

struct fb_cmap_user {};

struct fb_image_user {};

struct fb_cursor_user {};

/*
 * Register/unregister for framebuffer events
 */

/*	The resolution of the passed in fb_info about to change */
#define FB_EVENT_MODE_CHANGE

#ifdef CONFIG_GUMSTIX_AM200EPD
/* only used by mach-pxa/am200epd.c */
#define FB_EVENT_FB_REGISTERED
#define FB_EVENT_FB_UNREGISTERED
#endif

/*      A display blank is requested       */
#define FB_EVENT_BLANK

struct fb_event {};

/*	Enough for the VT console needs, see its max_font_width/height */
#define FB_MAX_BLIT_WIDTH
#define FB_MAX_BLIT_HEIGHT

struct fb_blit_caps {};

#ifdef CONFIG_FB_NOTIFY
extern int fb_register_client(struct notifier_block *nb);
extern int fb_unregister_client(struct notifier_block *nb);
extern int fb_notifier_call_chain(unsigned long val, void *v);
#else
static inline int fb_register_client(struct notifier_block *nb)
{
	return 0;
};

static inline int fb_unregister_client(struct notifier_block *nb)
{
	return 0;
};

static inline int fb_notifier_call_chain(unsigned long val, void *v)
{
	return 0;
};
#endif

/*
 * Pixmap structure definition
 *
 * The purpose of this structure is to translate data
 * from the hardware independent format of fbdev to what
 * format the hardware needs.
 */

#define FB_PIXMAP_DEFAULT
#define FB_PIXMAP_SYSTEM
#define FB_PIXMAP_IO
#define FB_PIXMAP_SYNC

struct fb_pixmap {};

#ifdef CONFIG_FB_DEFERRED_IO
struct fb_deferred_io_pageref {};

struct fb_deferred_io {};
#endif

/*
 * Frame buffer operations
 *
 * LOCKING NOTE: those functions must _ALL_ be called with the console
 * semaphore held, this is the only suitable locking mechanism we have
 * in 2.6. Some may be called at interrupt time at this point though.
 *
 * The exception to this is the debug related hooks.  Putting the fb
 * into a debug state (e.g. flipping to the kernel console) and restoring
 * it must be done in a lock-free manner, so low level drivers should
 * keep track of the initial console (if applicable) and may need to
 * perform direct, unlocked hardware writes in these hooks.
 */

struct fb_ops {};

#ifdef CONFIG_FB_TILEBLITTING
#define FB_TILE_CURSOR_NONE
#define FB_TILE_CURSOR_UNDERLINE
#define FB_TILE_CURSOR_LOWER_THIRD
#define FB_TILE_CURSOR_LOWER_HALF
#define FB_TILE_CURSOR_TWO_THIRDS
#define FB_TILE_CURSOR_BLOCK

struct fb_tilemap {};

struct fb_tilerect {};

struct fb_tilearea {};

struct fb_tileblit {};

struct fb_tilecursor {};

struct fb_tile_ops {};
#endif /* CONFIG_FB_TILEBLITTING */

/* FBINFO_* = fb_info.flags bit flags */
#define FBINFO_HWACCEL_DISABLED
	/* When FBINFO_HWACCEL_DISABLED is set:
	 *  Hardware acceleration is turned off.  Software implementations
	 *  of required functions (copyarea(), fillrect(), and imageblit())
	 *  takes over; acceleration engine should be in a quiescent state */

/* hints */
#define FBINFO_VIRTFB
#define FBINFO_PARTIAL_PAN_OK
#define FBINFO_READS_FAST

/* hardware supported ops */
/*  semantics: when a bit is set, it indicates that the operation is
 *   accelerated by hardware.
 *  required functions will still work even if the bit is not set.
 *  optional functions may not even exist if the flag bit is not set.
 */
#define FBINFO_HWACCEL_NONE
#define FBINFO_HWACCEL_COPYAREA
#define FBINFO_HWACCEL_FILLRECT
#define FBINFO_HWACCEL_IMAGEBLIT
#define FBINFO_HWACCEL_ROTATE
#define FBINFO_HWACCEL_XPAN
#define FBINFO_HWACCEL_YPAN
#define FBINFO_HWACCEL_YWRAP

#define FBINFO_MISC_TILEBLITTING

/* A driver may set this flag to indicate that it does want a set_par to be
 * called every time when fbcon_switch is executed. The advantage is that with
 * this flag set you can really be sure that set_par is always called before
 * any of the functions dependent on the correct hardware state or altering
 * that state, even if you are using some broken X releases. The disadvantage
 * is that it introduces unwanted delays to every console switch if set_par
 * is slow. It is a good idea to try this flag in the drivers initialization
 * code whenever there is a bug report related to switching between X and the
 * framebuffer console.
 */
#define FBINFO_MISC_ALWAYS_SETPAR

/*
 * Host and GPU endianness differ.
 */
#define FBINFO_FOREIGN_ENDIAN
/*
 * Big endian math. This is the same flags as above, but with different
 * meaning, it is set by the fb subsystem depending FOREIGN_ENDIAN flag
 * and host endianness. Drivers should not use this flag.
 */
#define FBINFO_BE_MATH
/*
 * Hide smem_start in the FBIOGET_FSCREENINFO IOCTL. This is used by modern DRM
 * drivers to stop userspace from trying to share buffers behind the kernel's
 * back. Instead dma-buf based buffer sharing should be used.
 */
#define FBINFO_HIDE_SMEM_START


struct fb_info {};

/* This will go away
 * fbset currently hacks in FB_ACCELF_TEXT into var.accel_flags
 * when it wants to turn the acceleration engine on.  This is
 * really a separate operation, and should be modified via sysfs.
 *  But for now, we leave it broken with the following define
 */
#define STUPID_ACCELF_TEXT_SHIT

#define FB_LEFT_POS(p, bpp)
#define FB_SHIFT_HIGH(p, val, bits)
#define FB_SHIFT_LOW(p, val, bits)

    /*
     *  `Generic' versions of the frame buffer device operations
     */

extern int fb_set_var(struct fb_info *info, struct fb_var_screeninfo *var);
extern int fb_pan_display(struct fb_info *info, struct fb_var_screeninfo *var);
extern int fb_blank(struct fb_info *info, int blank);

/*
 * Helpers for framebuffers in I/O memory
 */

extern void cfb_fillrect(struct fb_info *info, const struct fb_fillrect *rect);
extern void cfb_copyarea(struct fb_info *info, const struct fb_copyarea *area);
extern void cfb_imageblit(struct fb_info *info, const struct fb_image *image);
extern ssize_t fb_io_read(struct fb_info *info, char __user *buf,
			  size_t count, loff_t *ppos);
extern ssize_t fb_io_write(struct fb_info *info, const char __user *buf,
			   size_t count, loff_t *ppos);
int fb_io_mmap(struct fb_info *info, struct vm_area_struct *vma);

#define __FB_DEFAULT_IOMEM_OPS_RDWR

#define __FB_DEFAULT_IOMEM_OPS_DRAW

#define __FB_DEFAULT_IOMEM_OPS_MMAP

#define FB_DEFAULT_IOMEM_OPS

/*
 * Helpers for framebuffers in system memory
 */

extern void sys_fillrect(struct fb_info *info, const struct fb_fillrect *rect);
extern void sys_copyarea(struct fb_info *info, const struct fb_copyarea *area);
extern void sys_imageblit(struct fb_info *info, const struct fb_image *image);
extern ssize_t fb_sys_read(struct fb_info *info, char __user *buf,
			   size_t count, loff_t *ppos);
extern ssize_t fb_sys_write(struct fb_info *info, const char __user *buf,
			    size_t count, loff_t *ppos);

#define __FB_DEFAULT_SYSMEM_OPS_RDWR

#define __FB_DEFAULT_SYSMEM_OPS_DRAW

/*
 * Helpers for framebuffers in DMA-able memory
 */

#define __FB_DEFAULT_DMAMEM_OPS_RDWR

#define __FB_DEFAULT_DMAMEM_OPS_DRAW

/* fbmem.c */
extern int register_framebuffer(struct fb_info *fb_info);
extern void unregister_framebuffer(struct fb_info *fb_info);
extern int devm_register_framebuffer(struct device *dev, struct fb_info *fb_info);
extern char* fb_get_buffer_offset(struct fb_info *info, struct fb_pixmap *buf, u32 size);
extern void fb_pad_unaligned_buffer(u8 *dst, u32 d_pitch, u8 *src, u32 idx,
				u32 height, u32 shift_high, u32 shift_low, u32 mod);
extern void fb_pad_aligned_buffer(u8 *dst, u32 d_pitch, u8 *src, u32 s_pitch, u32 height);
extern void fb_set_suspend(struct fb_info *info, int state);
extern int fb_get_color_depth(struct fb_var_screeninfo *var,
			      struct fb_fix_screeninfo *fix);
extern int fb_get_options(const char *name, char **option);
extern int fb_new_modelist(struct fb_info *info);

static inline void lock_fb_info(struct fb_info *info)
{}

static inline void unlock_fb_info(struct fb_info *info)
{}

static inline void __fb_pad_aligned_buffer(u8 *dst, u32 d_pitch,
					   u8 *src, u32 s_pitch, u32 height)
{}

/* fb_defio.c */
int fb_deferred_io_mmap(struct fb_info *info, struct vm_area_struct *vma);
extern int  fb_deferred_io_init(struct fb_info *info);
extern void fb_deferred_io_open(struct fb_info *info,
				struct inode *inode,
				struct file *file);
extern void fb_deferred_io_release(struct fb_info *info);
extern void fb_deferred_io_cleanup(struct fb_info *info);
extern int fb_deferred_io_fsync(struct file *file, loff_t start,
				loff_t end, int datasync);

/*
 * Generate callbacks for deferred I/O
 */

#define __FB_GEN_DEFAULT_DEFERRED_OPS_RDWR(__prefix, __damage_range, __mode)

#define __FB_GEN_DEFAULT_DEFERRED_OPS_DRAW(__prefix, __damage_area, __mode)

#define FB_GEN_DEFAULT_DEFERRED_IOMEM_OPS(__prefix, __damage_range, __damage_area)

#define FB_GEN_DEFAULT_DEFERRED_SYSMEM_OPS(__prefix, __damage_range, __damage_area)

#define FB_GEN_DEFAULT_DEFERRED_DMAMEM_OPS(__prefix, __damage_range, __damage_area)

/*
 * Initializes struct fb_ops for deferred I/O.
 */

#define __FB_DEFAULT_DEFERRED_OPS_RDWR(__prefix)

#define __FB_DEFAULT_DEFERRED_OPS_DRAW(__prefix)

#define __FB_DEFAULT_DEFERRED_OPS_MMAP(__prefix)

#define FB_DEFAULT_DEFERRED_OPS(__prefix)

static inline bool fb_be_math(struct fb_info *info)
{}

extern struct fb_info *framebuffer_alloc(size_t size, struct device *dev);
extern void framebuffer_release(struct fb_info *info);
extern void fb_bl_default_curve(struct fb_info *fb_info, u8 off, u8 min, u8 max);

#if IS_ENABLED(CONFIG_FB_BACKLIGHT)
struct backlight_device *fb_bl_device(struct fb_info *info);
#else
static inline struct backlight_device *fb_bl_device(struct fb_info *info)
{
	return NULL;
}
#endif

/* fbmon.c */
#define FB_MAXTIMINGS
#define FB_VSYNCTIMINGS
#define FB_HSYNCTIMINGS
#define FB_DCLKTIMINGS
#define FB_IGNOREMON

#define FB_MODE_IS_UNKNOWN
#define FB_MODE_IS_DETAILED
#define FB_MODE_IS_STANDARD
#define FB_MODE_IS_VESA
#define FB_MODE_IS_CALCULATED
#define FB_MODE_IS_FIRST
#define FB_MODE_IS_FROM_VAR

extern int fbmon_dpms(const struct fb_info *fb_info);
extern int fb_get_mode(int flags, u32 val, struct fb_var_screeninfo *var,
		       struct fb_info *info);
extern int fb_validate_mode(const struct fb_var_screeninfo *var,
			    struct fb_info *info);
extern int fb_parse_edid(unsigned char *edid, struct fb_var_screeninfo *var);
extern const unsigned char *fb_firmware_edid(struct device *device);
extern void fb_edid_to_monspecs(unsigned char *edid,
				struct fb_monspecs *specs);
extern void fb_destroy_modedb(struct fb_videomode *modedb);
extern int fb_find_mode_cvt(struct fb_videomode *mode, int margins, int rb);
extern unsigned char *fb_ddc_read(struct i2c_adapter *adapter);

extern int of_get_fb_videomode(struct device_node *np,
			       struct fb_videomode *fb,
			       int index);
extern int fb_videomode_from_videomode(const struct videomode *vm,
				       struct fb_videomode *fbmode);

/* modedb.c */
#define VESA_MODEDB_SIZE
#define DMT_SIZE

extern void fb_var_to_videomode(struct fb_videomode *mode,
				const struct fb_var_screeninfo *var);
extern void fb_videomode_to_var(struct fb_var_screeninfo *var,
				const struct fb_videomode *mode);
extern int fb_mode_is_equal(const struct fb_videomode *mode1,
			    const struct fb_videomode *mode2);
extern int fb_add_videomode(const struct fb_videomode *mode,
			    struct list_head *head);
extern void fb_delete_videomode(const struct fb_videomode *mode,
				struct list_head *head);
extern const struct fb_videomode *fb_match_mode(const struct fb_var_screeninfo *var,
						struct list_head *head);
extern const struct fb_videomode *fb_find_best_mode(const struct fb_var_screeninfo *var,
						    struct list_head *head);
extern const struct fb_videomode *fb_find_nearest_mode(const struct fb_videomode *mode,
						       struct list_head *head);
extern void fb_destroy_modelist(struct list_head *head);
extern void fb_videomode_to_modelist(const struct fb_videomode *modedb, int num,
				     struct list_head *head);
extern const struct fb_videomode *fb_find_best_display(const struct fb_monspecs *specs,
						       struct list_head *head);

/* fbcmap.c */
extern int fb_alloc_cmap(struct fb_cmap *cmap, int len, int transp);
extern int fb_alloc_cmap_gfp(struct fb_cmap *cmap, int len, int transp, gfp_t flags);
extern void fb_dealloc_cmap(struct fb_cmap *cmap);
extern int fb_copy_cmap(const struct fb_cmap *from, struct fb_cmap *to);
extern int fb_cmap_to_user(const struct fb_cmap *from, struct fb_cmap_user *to);
extern int fb_set_cmap(struct fb_cmap *cmap, struct fb_info *fb_info);
extern int fb_set_user_cmap(struct fb_cmap_user *cmap, struct fb_info *fb_info);
extern const struct fb_cmap *fb_default_cmap(int len);
extern void fb_invert_cmaps(void);

struct fb_videomode {};

struct dmt_videomode {};

extern const struct fb_videomode vesa_modes[];
extern const struct dmt_videomode dmt_modes[];

struct fb_modelist {};

extern int fb_find_mode(struct fb_var_screeninfo *var,
			struct fb_info *info, const char *mode_option,
			const struct fb_videomode *db,
			unsigned int dbsize,
			const struct fb_videomode *default_mode,
			unsigned int default_bpp);

bool fb_modesetting_disabled(const char *drvname);

/*
 * Convenience logging macros
 */

#define fb_err(fb_info, fmt, ...)
#define fb_notice(info, fmt, ...)
#define fb_warn(fb_info, fmt, ...)
#define fb_info(fb_info, fmt, ...)
#define fb_dbg(fb_info, fmt, ...)

#define fb_warn_once(fb_info, fmt, ...)

#define fb_WARN_ONCE(fb_info, condition, fmt, ...)
#define fb_WARN_ON_ONCE(fb_info, x)

#endif /* _LINUX_FB_H */