2018-07-04 00:03:47 +08:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0 */
|
|
|
|
|
|
|
|
#ifndef _DRM_CLIENT_H_
|
|
|
|
#define _DRM_CLIENT_H_
|
|
|
|
|
2019-05-31 22:01:11 +08:00
|
|
|
#include <linux/lockdep.h>
|
|
|
|
#include <linux/mutex.h>
|
2018-07-04 00:03:47 +08:00
|
|
|
#include <linux/types.h>
|
|
|
|
|
2019-06-08 23:26:53 +08:00
|
|
|
#include <drm/drm_connector.h>
|
2019-05-31 22:01:11 +08:00
|
|
|
#include <drm/drm_crtc.h>
|
|
|
|
|
2018-07-04 00:03:47 +08:00
|
|
|
struct drm_client_dev;
|
|
|
|
struct drm_device;
|
|
|
|
struct drm_file;
|
|
|
|
struct drm_framebuffer;
|
|
|
|
struct drm_gem_object;
|
2018-07-04 00:03:51 +08:00
|
|
|
struct drm_minor;
|
2018-07-04 00:03:47 +08:00
|
|
|
struct module;
|
|
|
|
|
2019-05-31 22:01:11 +08:00
|
|
|
#define DRM_CLIENT_MAX_CLONED_CONNECTORS 8
|
|
|
|
|
2018-07-04 00:03:47 +08:00
|
|
|
/**
|
|
|
|
* struct drm_client_funcs - DRM client callbacks
|
|
|
|
*/
|
|
|
|
struct drm_client_funcs {
|
|
|
|
/**
|
|
|
|
* @owner: The module owner
|
|
|
|
*/
|
|
|
|
struct module *owner;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @unregister:
|
|
|
|
*
|
|
|
|
* Called when &drm_device is unregistered. The client should respond by
|
2019-02-02 09:23:26 +08:00
|
|
|
* releasing its resources using drm_client_release().
|
2018-07-04 00:03:47 +08:00
|
|
|
*
|
|
|
|
* This callback is optional.
|
|
|
|
*/
|
|
|
|
void (*unregister)(struct drm_client_dev *client);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @restore:
|
|
|
|
*
|
|
|
|
* Called on drm_lastclose(). The first client instance in the list that
|
|
|
|
* returns zero gets the privilege to restore and no more clients are
|
|
|
|
* called. This callback is not called after @unregister has been called.
|
|
|
|
*
|
|
|
|
* This callback is optional.
|
|
|
|
*/
|
|
|
|
int (*restore)(struct drm_client_dev *client);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @hotplug:
|
|
|
|
*
|
|
|
|
* Called on drm_kms_helper_hotplug_event().
|
|
|
|
* This callback is not called after @unregister has been called.
|
|
|
|
*
|
|
|
|
* This callback is optional.
|
|
|
|
*/
|
|
|
|
int (*hotplug)(struct drm_client_dev *client);
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* struct drm_client_dev - DRM client instance
|
|
|
|
*/
|
|
|
|
struct drm_client_dev {
|
|
|
|
/**
|
|
|
|
* @dev: DRM device
|
|
|
|
*/
|
|
|
|
struct drm_device *dev;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @name: Name of the client.
|
|
|
|
*/
|
|
|
|
const char *name;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @list:
|
|
|
|
*
|
|
|
|
* List of all clients of a DRM device, linked into
|
|
|
|
* &drm_device.clientlist. Protected by &drm_device.clientlist_mutex.
|
|
|
|
*/
|
|
|
|
struct list_head list;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @funcs: DRM client functions (optional)
|
|
|
|
*/
|
|
|
|
const struct drm_client_funcs *funcs;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @file: DRM file
|
|
|
|
*/
|
|
|
|
struct drm_file *file;
|
2019-05-31 22:01:11 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @modeset_mutex: Protects @modesets.
|
|
|
|
*/
|
|
|
|
struct mutex modeset_mutex;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @modesets: CRTC configurations
|
|
|
|
*/
|
|
|
|
struct drm_mode_set *modesets;
|
2018-07-04 00:03:47 +08:00
|
|
|
};
|
|
|
|
|
2018-10-02 03:45:36 +08:00
|
|
|
int drm_client_init(struct drm_device *dev, struct drm_client_dev *client,
|
|
|
|
const char *name, const struct drm_client_funcs *funcs);
|
2018-07-04 00:03:47 +08:00
|
|
|
void drm_client_release(struct drm_client_dev *client);
|
2019-04-03 20:56:58 +08:00
|
|
|
void drm_client_register(struct drm_client_dev *client);
|
2018-07-04 00:03:47 +08:00
|
|
|
|
|
|
|
void drm_client_dev_unregister(struct drm_device *dev);
|
|
|
|
void drm_client_dev_hotplug(struct drm_device *dev);
|
|
|
|
void drm_client_dev_restore(struct drm_device *dev);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* struct drm_client_buffer - DRM client buffer
|
|
|
|
*/
|
|
|
|
struct drm_client_buffer {
|
|
|
|
/**
|
|
|
|
* @client: DRM client
|
|
|
|
*/
|
|
|
|
struct drm_client_dev *client;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @handle: Buffer handle
|
|
|
|
*/
|
|
|
|
u32 handle;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @pitch: Buffer pitch
|
|
|
|
*/
|
|
|
|
u32 pitch;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @gem: GEM object backing this buffer
|
|
|
|
*/
|
|
|
|
struct drm_gem_object *gem;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @vaddr: Virtual address for the buffer
|
|
|
|
*/
|
|
|
|
void *vaddr;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @fb: DRM framebuffer
|
|
|
|
*/
|
|
|
|
struct drm_framebuffer *fb;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct drm_client_buffer *
|
|
|
|
drm_client_framebuffer_create(struct drm_client_dev *client, u32 width, u32 height, u32 format);
|
|
|
|
void drm_client_framebuffer_delete(struct drm_client_buffer *buffer);
|
|
|
|
|
2019-05-31 22:01:11 +08:00
|
|
|
int drm_client_modeset_create(struct drm_client_dev *client);
|
|
|
|
void drm_client_modeset_free(struct drm_client_dev *client);
|
|
|
|
void drm_client_modeset_release(struct drm_client_dev *client);
|
|
|
|
struct drm_mode_set *drm_client_find_modeset(struct drm_client_dev *client, struct drm_crtc *crtc);
|
2019-05-31 22:01:13 +08:00
|
|
|
bool drm_client_panel_rotation(struct drm_mode_set *modeset, unsigned int *rotation);
|
|
|
|
int drm_client_modeset_commit_force(struct drm_client_dev *client);
|
|
|
|
int drm_client_modeset_commit(struct drm_client_dev *client);
|
|
|
|
int drm_client_modeset_dpms(struct drm_client_dev *client, int mode);
|
2019-05-31 22:01:11 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* drm_client_for_each_modeset() - Iterate over client modesets
|
|
|
|
* @modeset: &drm_mode_set loop cursor
|
|
|
|
* @client: DRM client
|
|
|
|
*/
|
|
|
|
#define drm_client_for_each_modeset(modeset, client) \
|
|
|
|
for (({ lockdep_assert_held(&(client)->modeset_mutex); }), \
|
|
|
|
modeset = (client)->modesets; modeset->crtc; modeset++)
|
|
|
|
|
2019-06-08 23:26:53 +08:00
|
|
|
/**
|
|
|
|
* drm_client_for_each_connector_iter - connector_list iterator macro
|
|
|
|
* @connector: &struct drm_connector pointer used as cursor
|
|
|
|
* @iter: &struct drm_connector_list_iter
|
|
|
|
*
|
|
|
|
* This iterates the connectors that are useable for internal clients (excludes
|
|
|
|
* writeback connectors).
|
|
|
|
*
|
|
|
|
* For more info see drm_for_each_connector_iter().
|
|
|
|
*/
|
|
|
|
#define drm_client_for_each_connector_iter(connector, iter) \
|
|
|
|
drm_for_each_connector_iter(connector, iter) \
|
|
|
|
if (connector->connector_type != DRM_MODE_CONNECTOR_WRITEBACK)
|
|
|
|
|
2018-07-04 00:03:51 +08:00
|
|
|
int drm_client_debugfs_init(struct drm_minor *minor);
|
|
|
|
|
2018-07-04 00:03:47 +08:00
|
|
|
#endif
|