linux/drivers/gpu/drm/vmwgfx/vmwgfx_vkms.c

// SPDX-License-Identifier: GPL-2.0 OR MIT
/**************************************************************************
 *
 * Copyright (c) 2024 Broadcom. All Rights Reserved. The term
 * “Broadcom” refers to Broadcom Inc. and/or its subsidiaries.
 *
 * Permission is hereby granted, free of charge, to any person obtaining a
 * copy of this software and associated documentation files (the
 * "Software"), to deal in the Software without restriction, including
 * without limitation the rights to use, copy, modify, merge, publish,
 * distribute, sub license, and/or sell copies of the Software, and to
 * permit persons to whom the Software is furnished to do so, subject to
 * the following conditions:
 *
 * The above copyright notice and this permission notice (including the
 * next paragraph) shall be included in all copies or substantial portions
 * of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
 * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM,
 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
 * USE OR OTHER DEALINGS IN THE SOFTWARE.
 *
 **************************************************************************/

#include "vmwgfx_vkms.h"

#include "vmwgfx_bo.h"
#include "vmwgfx_drv.h"
#include "vmwgfx_kms.h"

#include "vmw_surface_cache.h"

#include <drm/drm_crtc.h>
#include <drm/drm_debugfs_crc.h>
#include <drm/drm_print.h>
#include <drm/drm_vblank.h>

#include <linux/crc32.h>
#include <linux/delay.h>

#define GUESTINFO_VBLANK

static int
vmw_surface_sync(struct vmw_private *vmw,
		 struct vmw_surface *surf)
{}

static void
compute_crc(struct drm_crtc *crtc,
	    struct vmw_surface *surf,
	    u32 *crc)
{}

static void
crc_generate_worker(struct work_struct *work)
{}

static enum hrtimer_restart
vmw_vkms_vblank_simulate(struct hrtimer *timer)
{}

void
vmw_vkms_init(struct vmw_private *vmw)
{}

void
vmw_vkms_cleanup(struct vmw_private *vmw)
{}

bool
vmw_vkms_get_vblank_timestamp(struct drm_crtc *crtc,
			      int *max_error,
			      ktime_t *vblank_time,
			      bool in_vblank_irq)
{}

int
vmw_vkms_enable_vblank(struct drm_crtc *crtc)
{}

void
vmw_vkms_disable_vblank(struct drm_crtc *crtc)
{}

enum vmw_vkms_lock_state {};

void
vmw_vkms_crtc_init(struct drm_crtc *crtc)
{}

void
vmw_vkms_crtc_cleanup(struct drm_crtc *crtc)
{}

void
vmw_vkms_crtc_atomic_begin(struct drm_crtc *crtc,
			   struct drm_atomic_state *state)
{}

void
vmw_vkms_crtc_atomic_flush(struct drm_crtc *crtc,
			   struct drm_atomic_state *state)
{}

void
vmw_vkms_crtc_atomic_enable(struct drm_crtc *crtc,
			    struct drm_atomic_state *state)
{}

void
vmw_vkms_crtc_atomic_disable(struct drm_crtc *crtc,
			     struct drm_atomic_state *state)
{}

static bool
is_crc_supported(struct drm_crtc *crtc)
{}

static const char * const pipe_crc_sources[] =;

static int
crc_parse_source(const char *src_name,
		 bool *enabled)
{}

const char *const *
vmw_vkms_get_crc_sources(struct drm_crtc *crtc,
			 size_t *count)
{}

int
vmw_vkms_verify_crc_source(struct drm_crtc *crtc,
			   const char *src_name,
			   size_t *values_cnt)
{}

int
vmw_vkms_set_crc_source(struct drm_crtc *crtc,
			const char *src_name)
{}

void
vmw_vkms_set_crc_surface(struct drm_crtc *crtc,
			 struct vmw_surface *surf)
{}

/**
 * vmw_vkms_lock_max_wait_ns - Return the max wait for the vkms lock
 * @du: The vmw_display_unit from which to grab the vblank timings
 *
 * Returns the maximum wait time used to acquire the vkms lock. By
 * default uses a time of a single frame and in case where vblank
 * was not initialized for the display unit 1/60th of a second.
 */
static inline u64
vmw_vkms_lock_max_wait_ns(struct vmw_display_unit *du)
{}

/**
 * vmw_vkms_modeset_lock - Protects access to crtc during modeset
 * @crtc: The crtc to lock for vkms
 *
 * This function prevents the VKMS timers/callbacks from being called
 * while a modeset operation is in process. We don't want the callbacks
 * e.g. the vblank simulator to be trying to access incomplete state
 * so we need to make sure they execute only when the modeset has
 * finished.
 *
 * Normally this would have been done with a spinlock but locking the
 * entire atomic modeset with vmwgfx is impossible because kms prepare
 * executes non-atomic ops (e.g. vmw_validation_prepare holds a mutex to
 * guard various bits of state). Which means that we need to synchronize
 * atomic context (the vblank handler) with the non-atomic entirity
 * of kms - so use an atomic_t to track which part of vkms has access
 * to the basic vkms state.
 */
void
vmw_vkms_modeset_lock(struct drm_crtc *crtc)
{}

/**
 * vmw_vkms_modeset_lock_relaxed - Protects access to crtc during modeset
 * @crtc: The crtc to lock for vkms
 *
 * Much like vmw_vkms_modeset_lock except that when the crtc is currently
 * in a modeset it will return immediately.
 *
 * Returns true if actually locked vkms to modeset or false otherwise.
 */
bool
vmw_vkms_modeset_lock_relaxed(struct drm_crtc *crtc)
{}

/**
 * vmw_vkms_vblank_trylock - Protects access to crtc during vblank
 * @crtc: The crtc to lock for vkms
 *
 * Tries to lock vkms for vblank, returns immediately.
 *
 * Returns true if locked vkms to vblank or false otherwise.
 */
bool
vmw_vkms_vblank_trylock(struct drm_crtc *crtc)
{}

void
vmw_vkms_unlock(struct drm_crtc *crtc)
{}