Home | History | Annotate | Download | only in inc
      1 /*
      2  * Copyright (C) 2014 Intel Corporation. All rights reserved.
      3  *
      4  * Licensed under the Apache License, Version 2.0 (the "License");
      5  * you may not use this file except in compliance with the License.
      6  * You may obtain a copy of the License at
      7  *
      8  *      http://www.apache.org/licenses/LICENSE-2.0
      9  *
     10  * Unless required by applicable law or agreed to in writing, software
     11  * distributed under the License is distributed on an "AS IS" BASIS,
     12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13  * See the License for the specific language governing permissions and
     14  * limitations under the License.
     15  */
     16 
     17 #ifndef __DRM_COMMON_API_H__
     18 #define __DRM_COMMON_API_H__
     19 
     20 #include <inttypes.h>
     21 
     22 /*
     23  * Maximum number of bytes for an audio or video data DMA.
     24  */
     25 #define MAX_DMA_DATA_SIZE_IN_BYTES (4 * 1024 * 1024)
     26 
     27 /*
     28  * The size of an AES Initialization Vector counter in bytes.
     29  */
     30 #define AES_IV_COUNTER_SIZE_IN_BYTES 16
     31 
     32 #define DRM_PLATCAP_IED         0x01
     33 #define DRM_PLATCAP_IMR         0x02
     34 #define DRM_PLATCAP_EPID        0x04
     35 #define DRM_PLATCAP_HDCP        0x08
     36 
     37 // Secure clock transaction ID (TID) size in bytes.
     38 #define DRM_TID_SIZE 16
     39 
     40 #define MAX_RNG_SIZE_IN_BYTES (4 * 1024)
     41 
     42 //
     43 // Secure clock time of day data type.
     44 // day_of_month: starts with 1.
     45 // month: 0 = January.
     46 // year: Epoch is 70 (i.e., 1970). Maximum value is 138 (i.e., 2038).
     47 //
     48 struct time_of_day
     49 {
     50     uint8_t sec;
     51     uint8_t min;
     52     uint8_t hour;
     53     uint8_t day_of_week;
     54     uint8_t day_of_month;
     55     uint8_t month;
     56     uint8_t year;
     57     uint8_t padding;
     58 };
     59 
     60 
     61 //
     62 // Secure clock server response data type.
     63 //
     64 struct drm_secureclock_server_response
     65 {
     66     uint8_t tid[DRM_TID_SIZE];
     67     struct time_of_day current_time;
     68     struct time_of_day refresh_time;
     69     uint8_t signature[256];
     70 };
     71 
     72 
     73 /*
     74  * DRM Schemes
     75  */
     76 /*
     77    typedef enum {
     78         DRM_SCHEME_Netflix,
     79         DRM_SCHEME_Widevine,
     80         DRM_SCHEME_WidevineHLS,
     81    } drm_scheme_t;
     82  */
     83 
     84 
     85 struct drm_platform_caps
     86 {
     87     uint32_t imr_size;
     88     uint32_t reserved[15];
     89 };
     90 
     91 
     92 /*
     93  * DRM Library Initialization
     94  * Description:
     95  *  Initializes the security engine driver for DRM library use.
     96  */
     97 uint32_t drm_library_init(void);
     98 
     99 /*
    100  * @brief Writes random bytes into buffer
    101  */
    102 uint32_t drm_get_random(
    103     uint8_t *rand_num_buf,
    104     uint32_t buf_size);
    105 
    106 /*!
    107  * Create a DRM session
    108  */
    109 uint32_t drm_create_session(
    110     uint32_t drm_scheme,
    111     uint32_t *sessionid_ptr);
    112 
    113 /*!
    114  * Destroy the specified DRM session
    115  */
    116 uint32_t drm_destroy_session(
    117     uint32_t session_id);
    118 
    119 
    120 /*
    121  * Keeps an active DRM session from timing out
    122  */
    123 uint32_t drm_keep_alive(
    124     uint32_t session_id,
    125     uint32_t *timeout);
    126 
    127 /*
    128  * Query secure platform capabilities
    129  */
    130 uint32_t drm_query_platformcapabilities(
    131     uint32_t *plat_cap,
    132     struct drm_platform_caps *cap_array);
    133 
    134 
    135 /*
    136  * @brief Pauses the playback of a video decryption session.
    137  * @param session_id The ID number of the session to pause playback.
    138  * @return DRM_SUCCESSFUL The video decryption session was paused.
    139  */
    140 uint32_t drm_playback_pause(
    141     uint32_t session_id);
    142 
    143 
    144 /*
    145  * @brief Resumes the playback of a paused video decryption session.
    146  * @param session_id The ID number of the session to resume playback.
    147  * @return DRM_SUCCESSFUL The video decryption session was resumed.
    148  */
    149 uint32_t drm_playback_resume(
    150     uint32_t session_id);
    151 
    152 
    153 /*!
    154  * @brief Enables protected video path for DRM playback
    155  */
    156 uint32_t drm_start_playback(void);
    157 
    158 
    159 /*!
    160  * @brief - Disables protected video path for DRM
    161  */
    162 uint32_t drm_stop_playback(void);
    163 
    164 #endif
    165