This source file includes following definitions.
- destruct
- construct
- dc_sink_retain
- dc_sink_free
- dc_sink_release
- dc_sink_create
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 #include <linux/slab.h>
27
28 #include "dm_services.h"
29 #include "dm_helpers.h"
30 #include "core_types.h"
31
32
33
34
35
36 static void destruct(struct dc_sink *sink)
37 {
38 if (sink->dc_container_id) {
39 kfree(sink->dc_container_id);
40 sink->dc_container_id = NULL;
41 }
42 }
43
44 static bool construct(struct dc_sink *sink, const struct dc_sink_init_data *init_params)
45 {
46
47 struct dc_link *link = init_params->link;
48
49 if (!link)
50 return false;
51
52 sink->sink_signal = init_params->sink_signal;
53 sink->link = link;
54 sink->ctx = link->ctx;
55 sink->dongle_max_pix_clk = init_params->dongle_max_pix_clk;
56 sink->converter_disable_audio = init_params->converter_disable_audio;
57 sink->dc_container_id = NULL;
58 sink->sink_id = init_params->link->ctx->dc_sink_id_count;
59
60
61 init_params->link->ctx->dc_sink_id_count++;
62
63 return true;
64 }
65
66
67
68
69
70 void dc_sink_retain(struct dc_sink *sink)
71 {
72 kref_get(&sink->refcount);
73 }
74
75 static void dc_sink_free(struct kref *kref)
76 {
77 struct dc_sink *sink = container_of(kref, struct dc_sink, refcount);
78 destruct(sink);
79 kfree(sink);
80 }
81
82 void dc_sink_release(struct dc_sink *sink)
83 {
84 kref_put(&sink->refcount, dc_sink_free);
85 }
86
87 struct dc_sink *dc_sink_create(const struct dc_sink_init_data *init_params)
88 {
89 struct dc_sink *sink = kzalloc(sizeof(*sink), GFP_KERNEL);
90
91 if (NULL == sink)
92 goto alloc_fail;
93
94 if (false == construct(sink, init_params))
95 goto construct_fail;
96
97 kref_init(&sink->refcount);
98
99 return sink;
100
101 construct_fail:
102 kfree(sink);
103
104 alloc_fail:
105 return NULL;
106 }
107
108
109
110