summaryrefslogtreecommitdiff
path: root/DRM/cc54/inc/drm_common_api.h
blob: 44d7bc232812f2c36c92b9237de452caa8d11e81 (plain)
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
/*
 * Copyright (C) 2014 Intel Corporation. All rights reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#ifndef __DRM_COMMON_API_H__
#define __DRM_COMMON_API_H__

#include <inttypes.h>

/*
 * Maximum number of bytes for an audio or video data DMA.
 */
#define MAX_DMA_DATA_SIZE_IN_BYTES (4 * 1024 * 1024)

/*
 * The size of an AES Initialization Vector counter in bytes.
 */
#define AES_IV_COUNTER_SIZE_IN_BYTES 16

#define DRM_PLATCAP_IED         0x01
#define DRM_PLATCAP_IMR         0x02
#define DRM_PLATCAP_EPID        0x04
#define DRM_PLATCAP_HDCP        0x08

// Secure clock transaction ID (TID) size in bytes.
#define DRM_TID_SIZE 16

#define MAX_RNG_SIZE_IN_BYTES (4 * 1024)

//
// Secure clock time of day data type.
// day_of_month: starts with 1.
// month: 0 = January.
// year: Epoch is 70 (i.e., 1970). Maximum value is 138 (i.e., 2038).
//
struct time_of_day
{
    uint8_t sec;
    uint8_t min;
    uint8_t hour;
    uint8_t day_of_week;
    uint8_t day_of_month;
    uint8_t month;
    uint8_t year;
    uint8_t padding;
};


//
// Secure clock server response data type.
//
struct drm_secureclock_server_response
{
    uint8_t tid[DRM_TID_SIZE];
    struct time_of_day current_time;
    struct time_of_day refresh_time;
    uint8_t signature[256];
};


/*
 * DRM Schemes
 */
/*
   typedef enum {
        DRM_SCHEME_Netflix,
        DRM_SCHEME_Widevine,
        DRM_SCHEME_WidevineHLS,
   } drm_scheme_t;
 */


struct drm_platform_caps
{
    uint32_t imr_size;
    uint32_t reserved[15];
};


/*
 * DRM Library Initialization
 * Description:
 *  Initializes the security engine driver for DRM library use.
 */
uint32_t drm_library_init(void);

/*
 * @brief Writes random bytes into buffer
 */
uint32_t drm_get_random(
    uint8_t *rand_num_buf,
    uint32_t buf_size);

/*!
 * Create a DRM session
 */
uint32_t drm_create_session(
    uint32_t drm_scheme,
    uint32_t *sessionid_ptr);

/*!
 * Destroy the specified DRM session
 */
uint32_t drm_destroy_session(
    uint32_t session_id);


/*
 * Keeps an active DRM session from timing out
 */
uint32_t drm_keep_alive(
    uint32_t session_id,
    uint32_t *timeout);

/*
 * Query secure platform capabilities
 */
uint32_t drm_query_platformcapabilities(
    uint32_t *plat_cap,
    struct drm_platform_caps *cap_array);


/*
 * @brief Pauses the playback of a video decryption session.
 * @param session_id The ID number of the session to pause playback.
 * @return DRM_SUCCESSFUL The video decryption session was paused.
 */
uint32_t drm_playback_pause(
    uint32_t session_id);


/*
 * @brief Resumes the playback of a paused video decryption session.
 * @param session_id The ID number of the session to resume playback.
 * @return DRM_SUCCESSFUL The video decryption session was resumed.
 */
uint32_t drm_playback_resume(
    uint32_t session_id);


/*!
 * @brief Enables protected video path for DRM playback
 */
uint32_t drm_start_playback(void);


/*!
 * @brief - Disables protected video path for DRM
 */
uint32_t drm_stop_playback(void);

#endif