File: evdi_encoder.c

package info (click to toggle)
evdi 1.9.0%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 384 kB
  • sloc: ansic: 4,651; makefile: 100; sh: 4
file content (72 lines) | stat: -rw-r--r-- 1,682 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
// SPDX-License-Identifier: GPL-2.0-only
/*
 * Copyright (C) 2012 Red Hat
 * Copyright (c) 2015 - 2020 DisplayLink (UK) Ltd.
 *
 * Based on parts on udlfb.c:
 * Copyright (C) 2009 its respective authors
 *
 * This file is subject to the terms and conditions of the GNU General Public
 * License v2. See the file COPYING in the main directory of this archive for
 * more details.
 */

#include <linux/version.h>
#if KERNEL_VERSION(5, 5, 0) <= LINUX_VERSION_CODE || defined(EL8)
#else
#include <drm/drmP.h>
#endif
#include <drm/drm_crtc.h>
#include <drm/drm_crtc_helper.h>
#include "evdi_drm_drv.h"

/* dummy encoder */
static void evdi_enc_destroy(struct drm_encoder *encoder)
{
	drm_encoder_cleanup(encoder);
	kfree(encoder);
}

static void evdi_encoder_enable(__always_unused struct drm_encoder *encoder)
{
}

static void evdi_encoder_disable(__always_unused struct drm_encoder *encoder)
{
}

static const struct drm_encoder_helper_funcs evdi_enc_helper_funcs = {
	.enable = evdi_encoder_enable,
	.disable = evdi_encoder_disable
};

static const struct drm_encoder_funcs evdi_enc_funcs = {
	.destroy = evdi_enc_destroy,
};

struct drm_encoder *evdi_encoder_init(struct drm_device *dev)
{
	struct drm_encoder *encoder;
	int ret = 0;

	encoder = kzalloc(sizeof(struct drm_encoder), GFP_KERNEL);
	if (!encoder)
		goto err;

	ret = drm_encoder_init(dev, encoder, &evdi_enc_funcs,
			       DRM_MODE_ENCODER_TMDS, dev_name(dev->dev));
	if (ret) {
		EVDI_ERROR("Failed to initialize encoder: %d\n", ret);
		goto err_encoder;
	}

	drm_encoder_helper_add(encoder, &evdi_enc_helper_funcs);

	encoder->possible_crtcs = 1;
	return encoder;

err_encoder:
	kfree(encoder);
err:
	return NULL;
}