diff options
author | Thierry Strudel <thierry.strudel@intel.com> | 2014-09-25 22:01:08 -0700 |
---|---|---|
committer | Patrick Tjin <pattjin@google.com> | 2014-09-25 22:31:35 -0700 |
commit | 58ab4ceb5ea3d2733f108cacfcccb93e0c8d84da (patch) | |
tree | 35994aa45e1a94584b40f7709c60c9fa369bde4c | |
parent | b7578c7f58cd6477eaa9307b66d00d655532527a (diff) | |
download | psb_headers-58ab4ceb5ea3d2733f108cacfcccb93e0c8d84da.tar.gz |
Add vendor libraries headersandroid-wear-5.1.1_r1android-wear-5.1.0_r1android-wear-5.0.0_r1android-m-preview-2android-m-preview-1android-m-previewandroid-cts-5.1_r9android-cts-5.1_r8android-cts-5.1_r7android-cts-5.1_r6android-cts-5.1_r5android-cts-5.1_r4android-cts-5.1_r3android-cts-5.1_r28android-cts-5.1_r27android-cts-5.1_r26android-cts-5.1_r25android-cts-5.1_r24android-cts-5.1_r23android-cts-5.1_r22android-cts-5.1_r21android-cts-5.1_r20android-cts-5.1_r2android-cts-5.1_r19android-cts-5.1_r18android-cts-5.1_r17android-cts-5.1_r16android-cts-5.1_r15android-cts-5.1_r14android-cts-5.1_r13android-cts-5.1_r10android-cts-5.1_r1android-cts-5.0_r9android-cts-5.0_r8android-cts-5.0_r7android-cts-5.0_r6android-cts-5.0_r5android-cts-5.0_r4android-cts-5.0_r3android-5.1.1_r9android-5.1.1_r8android-5.1.1_r7android-5.1.1_r6android-5.1.1_r5android-5.1.1_r4android-5.1.1_r38android-5.1.1_r37android-5.1.1_r36android-5.1.1_r35android-5.1.1_r34android-5.1.1_r33android-5.1.1_r30android-5.1.1_r3android-5.1.1_r29android-5.1.1_r28android-5.1.1_r26android-5.1.1_r25android-5.1.1_r24android-5.1.1_r23android-5.1.1_r22android-5.1.1_r20android-5.1.1_r2android-5.1.1_r19android-5.1.1_r18android-5.1.1_r17android-5.1.1_r16android-5.1.1_r15android-5.1.1_r14android-5.1.1_r13android-5.1.1_r12android-5.1.1_r10android-5.1.1_r1android-5.1.0_r5android-5.1.0_r4android-5.1.0_r3android-5.1.0_r1android-5.0.2_r3android-5.0.2_r1android-5.0.1_r1android-5.0.0_r7android-5.0.0_r6android-5.0.0_r5.1android-5.0.0_r5android-5.0.0_r4android-5.0.0_r3android-5.0.0_r2android-5.0.0_r1master-soonglollipop-wear-releaselollipop-releaselollipop-mr1-wfc-releaselollipop-mr1-releaselollipop-mr1-fi-releaselollipop-mr1-devlollipop-mr1-cts-releaselollipop-devlollipop-cts-release
Vendor libraries headers needed to be in hardware tree to build open
source parts.
Bug: 17468185
Change-Id: I6ff7482b8e018f0fa720baed3eb71767c66381dd
Signed-off-by: Thierry Strudel <thierry.strudel@intel.com>
-rw-r--r-- | Android.mk | 25 | ||||
-rw-r--r-- | DRM/cc54/inc/drm_common_api.h | 164 | ||||
-rw-r--r-- | DRM/cc54/inc/drm_error.h | 64 | ||||
-rw-r--r-- | DRM/cc54/inc/pr_drm_api.h | 278 | ||||
-rw-r--r-- | DRM/cc54/inc/sepdrm.h | 39 | ||||
-rw-r--r-- | DRM/cc54/inc/wv_drm_api.h | 210 | ||||
-rw-r--r-- | DRM/cc54/inc/wv_fkp.h | 54 | ||||
-rw-r--r-- | DRM/cc54/inc/wv_mod_drm_api.h | 282 | ||||
-rw-r--r-- | DRM/cc54/inc/wv_mod_drm_error.h | 78 | ||||
-rw-r--r-- | DRM/cc54/inc/wv_mod_oem_crypto.h | 54 | ||||
-rw-r--r-- | libmediaparser/mixvbp/vbp_manager/include/vbp_loader.h | 475 |
11 files changed, 1723 insertions, 0 deletions
diff --git a/Android.mk b/Android.mk new file mode 100644 index 0000000..5b98120 --- /dev/null +++ b/Android.mk @@ -0,0 +1,25 @@ + +LOCAL_PATH := $(call my-dir) + +ifeq ($(TARGET_BOARD_PLATFORM),moorefield) + +include $(CLEAR_VARS) +LOCAL_COPY_HEADERS := \ + libmediaparser/mixvbp/vbp_manager/include/vbp_loader.h +LOCAL_COPY_HEADERS_TO := libmixvbp +include $(BUILD_COPY_HEADERS) + +include $(CLEAR_VARS) +LOCAL_COPY_HEADERS := \ + DRM/cc54/inc/sepdrm.h \ + DRM/cc54/inc/drm_common_api.h \ + DRM/cc54/inc/drm_error.h \ + DRM/cc54/inc/pr_drm_api.h \ + DRM/cc54/inc/wv_drm_api.h \ + DRM/cc54/inc/wv_fkp.h \ + DRM/cc54/inc/wv_mod_drm_api.h \ + DRM/cc54/inc/wv_mod_drm_error.h \ + DRM/cc54/inc/wv_mod_oem_crypto.h +include $(BUILD_COPY_HEADERS) + +endif # ifeq ($(TARGET_BOARD_PLATFORM),moorefield)
\ No newline at end of file diff --git a/DRM/cc54/inc/drm_common_api.h b/DRM/cc54/inc/drm_common_api.h new file mode 100644 index 0000000..44d7bc2 --- /dev/null +++ b/DRM/cc54/inc/drm_common_api.h @@ -0,0 +1,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 diff --git a/DRM/cc54/inc/drm_error.h b/DRM/cc54/inc/drm_error.h new file mode 100644 index 0000000..5ee3a67 --- /dev/null +++ b/DRM/cc54/inc/drm_error.h @@ -0,0 +1,64 @@ +/* + * 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_ERROR_H__ +#define __DRM_ERROR_H__ + + +enum +{ + DRM_SUCCESSFUL = 0, + + /*! DRM middleware and firmware errors */ + DRM_ERR_BASE = 0x50000000, + DRM_FAIL_INVALID_PARAM, + DRM_FAIL_NULL_PARAM, + DRM_FAIL_BUFFER_TOO_SMALL, + DRM_FAIL_UNSUPPORTED, + DRM_FAIL_INVALID_IMR_SIZE, + DRM_FAIL_INVALID_SESSION, + DRM_FAIL_FW_SESSION, + DRM_FAIL_AUDIO_DATA_NOT_VALID, + DRM_FAIL_INVALID_TEE_PARAM, + DRM_FAIL_KEYBOX_INVALID_BAD_MAGIC, + DRM_FAIL_KEYBOX_INVALID_BAD_CRC, + DRM_FAIL_KEYBOX_INVALID_BAD_PROVISIONING, + DRM_FAIL_KEYBOX_INVALID_NOT_PROVISIONED, + DRM_FAIL_INPUT_BUFFER_TOO_SHORT, + DRM_FAIL_AES_DECRYPT, // 0x5000000F + DRM_FAIL_AES_FAILURE, + DRM_FAIL_WV_NO_ASSET_KEY, + DRM_FAIL_WV_NO_CEK, + DRM_FAIL_SCHEDULER, + DRM_FAIL_SESSION_NOT_INITIALIZED, + DRM_FAIL_REPROVISION_IED_KEY, + DRM_FAIL_NALU_DATA_EXCEEDS_BUFFER_SIZE, + DRM_FAIL_WV_SESSION_NALU_PARSE_FAILURE, + DRM_FAIL_SESSION_KEY_GEN, + DRM_FAIL_INVALID_PLATFORM_ID, + DRM_FAIL_INVALID_MAJOR_VERSION, + DRM_FAIL_NO_PREV_PARTIAL_BLOCK, + DRM_FAIL_WRITE_KEYBOX, + DRM_FAIL_INSUFFICENT_RESOURCES, + + /*! Middleware specific errors */ + DRM_FAIL_GENERATE_RANDOM_NUMBER_FAILURE = 0x50001000, + DRM_FAIL_DX_CCLIB_INIT_FAILURE, + DRM_FAILURE = 0x5FFFFFFF +}; + + +#endif // drm_error.h diff --git a/DRM/cc54/inc/pr_drm_api.h b/DRM/cc54/inc/pr_drm_api.h new file mode 100644 index 0000000..1d90885 --- /dev/null +++ b/DRM/cc54/inc/pr_drm_api.h @@ -0,0 +1,278 @@ +/* + * 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. + */ + +/** + * @file drm_pr_api.h + * @brief Header file for Playready DRM API + */ + +#ifndef __DRM_PR_API_H__ +#define __DRM_PR_API_H__ + +/*! + * Defines + */ +#define PR_CLEAR_CONTENT_FLAG (1) + +#define DRM_SECURE_CLOCK_FLAG_RESET (1) + +/*! + * Structs + */ + +/* + * This structure is used to provide necessary information for PlayReady video + * ciphertext decryption. + * + * The members are: + * + * iv - AES initialization vector. + * input_ciphertext_size - Input ciphertext data size in bytes. + * p_input_ciphertext - Pointer to the input ciphertext data. + */ +struct pr_drm_video_cipher +{ + uint32_t key_index; + uint32_t key_type; + uint64_t iv; + uint64_t byte_offset; + uint32_t input_ciphertext_size; + uint8_t *p_input_ciphertext; + uint8_t flags; + uint8_t *p_output_enc_ciphertext; + uint32_t output_ciphertext_size; +}; + + +struct drm_nalu_headers +{ + uint32_t frame_size; + uint32_t parse_size; + uint8_t *p_enc_ciphertext; + uint32_t hdrs_buf_len; + uint8_t *p_hdrs_buf; +}; + +struct pr_av_secure_input_data_buffer +{ + uint32_t session_id; + uint32_t size; + uint8_t *data; + uint32_t clear; +}; + + +/* + * Map to Oem_Hal_AllocateRegister + */ +uint32_t drm_pr_allocate_register(uint32_t key_type, + uint32_t *key_reg_index); + +/* + * Map to Oem_Hal_FreeRegister + */ +uint32_t drm_pr_free_register(uint32_t key_type, + uint32_t key_reg_index); + +/* + * Map to Oem_Hal_RegisterCount + */ +uint32_t drm_pr_register_count(uint32_t key_type, + uint32_t *total_regs, + uint32_t *allocated_regs); + +/* + * Map to Oem_Hal_GetPreloadedIndex + */ +uint32_t drm_pr_get_preloaded_index(uint32_t key_type, + uint8_t *key_id, + uint32_t key_id_len, + uint32_t *key_index); +/* + * Map to Oem_Hal_Initialize + */ +uint32_t drm_pr_initialize(void); + +/* + * Map to Oem_Hal_Deinitialize + */ +uint32_t drm_pr_deinitialize(void); + +/* + * Map to Oem_Hal_VerifyMessageSignature + */ +uint32_t drm_pr_verify_message_signature(uint8_t *msg, + uint32_t msg_len, + const uint8_t *signature, + uint32_t signature_len, + uint32_t hash_type, + uint32_t signature_scheme, + uint32_t integrity_key_index); + +/* + * Map to Oem_Hal_CreateMessageSignature + */ +uint32_t drm_pr_create_message_signature(uint8_t *msg, + uint32_t msg_len, + uint8_t *signature, + uint32_t *signature_len, + uint32_t hash_type, + uint32_t signature_scheme, + uint32_t key_type, + uint32_t integrity_key_index); +/* + * Map to Oem_Hal_VerifyOMAC1Signature + */ + uint32_t drm_pr_verify_omac1_signature(uint8_t *msg, + uint32_t msg_len, + uint8_t *signature, + uint32_t signature_len, + uint32_t key_type, + uint32_t index_key); + + /* + * Map to Oem_Hal_CreateOMAC1Signature + */ +uint32_t drm_pr_create_omac1_signature(uint8_t *msg, + uint32_t msg_len, + uint8_t *signature, + uint32_t *signature_len, + uint32_t key_type, + uint32_t index_key); + +/* + * Map to Oem_Hal_UnwrapKey + */ +uint32_t drm_pr_unwrap_get_keydata_type(uint32_t key_type, + uint32_t key_index, + uint32_t wrapping_key_type, + uint32_t wrapping_key_index, + uint32_t *key_data_type); + +uint32_t drm_pr_unwrap_encrypted_key(uint32_t key_type, + uint32_t key_index, + uint32_t wrapping_key_type, + uint32_t wrapping_key_index, + uint8_t *encryption_key_info, + uint32_t key_info_size, + uint8_t *encrypted_key_data, + uint32_t key_data_size); + +uint32_t drm_pr_unwrap_xmr_license(uint32_t key_type, + uint32_t key_index, + uint32_t wrapping_key_type, + uint32_t wrapping_key_index, + uint8_t *xmr_license, + uint32_t xmr_license_size, + uint8_t xmr_ignore_cksum, + uint8_t bb_ignore_cksum, + uint8_t *bb_cksum_data, + uint32_t bb_cksum_data_size, + uint8_t *bb_kid, + uint8_t bb_kid_size, + uint8_t *bb_v1_kid, + uint32_t bb_v1_kid_size); + +uint32_t drm_pr_unwrap_key(uint32_t unwrap_key_type, + uint32_t unwrap_key_reg_index, + uint32_t wrapping_key_type, + uint32_t wrapping_key_index, + uint8_t *wrapped_key_data, + uint32_t wrapped_key_data_len, + const uint8_t *param_data, + uint32_t param_data_len); + +/* + * Map to Oem_Hal_WrapKey + */ +uint32_t drm_pr_wrap_get_encryption_type(uint32_t key_type, + uint32_t key_index, + uint32_t wrapping_key_type, + uint32_t wrapping_key_index, + uint32_t *encryption_type); + +uint32_t drm_pr_wrap_encrypted_key(uint32_t key_type, + uint32_t key_index, + uint32_t wrapping_key_type, + uint32_t wrapping_key_index, + uint8_t *encryption_key_info, + uint32_t key_info_size, + uint8_t *encrypted_key_data, + uint32_t encrypted_key_data_size); + +uint32_t drm_pr_wrap_key(uint32_t wrap_key_type, + uint32_t wrap_key_reg_index, + uint32_t wrapping_key_type, + uint32_t wrapping_key_reg_index, + uint8_t *wrapped_key, + uint32_t *wrapped_key_len); + +/* + * Map to Oem_Hal_GenerateKey + */ +uint32_t drm_pr_generate_key(uint32_t key_type, + uint32_t key_reg_index, + uint32_t security_level); +/* + * Map to Oem_Hal_LoadPlayReadyRevocationInfo + */ +uint32_t drm_pr_load_revoc_info(uint8_t *revoc_info, + uint32_t revoc_info_len, + uint32_t sign_key_reg_index); +/* + * Map to Oem_Hal_LoadPlayReadyCrl + */ +uint32_t drm_pr_load_crl(uint8_t *crl, + uint32_t crl_len, + uint32_t sign_key_reg_index); +/* + * Map to Oem_Hal_DecryptContentOpaque + */ +uint32_t drm_pr_decrypt_content_opaque(void *in_buffer, + void *out_buffer, + uint32_t data_len, + uint32_t key_type, + uint32_t key_index, + uint64_t iv, + uint64_t byte_offset); + +uint32_t drm_pr_decrypt_content(uint8_t *out_buffer, + uint32_t data_len, + uint32_t key_type, + uint32_t key_index, + uint64_t iv, + uint64_t byte_offset); + +/*! + *@brief Create a PlayReady session + * + */ +uint32_t drm_pr_create_session(uint32_t *session_id); + +/*! + *@brief Returns NALU header + * + */ +uint32_t drm_pr_return_naluheaders(uint32_t session_id, + struct drm_nalu_headers *nalu_info); + +/*! + *@brief Returns SRTC time + * + */ +uint32_t drm_pr_get_srtc_time(uint32_t *time, + uint32_t *flags); +#endif diff --git a/DRM/cc54/inc/sepdrm.h b/DRM/cc54/inc/sepdrm.h new file mode 100644 index 0000000..6996117 --- /dev/null +++ b/DRM/cc54/inc/sepdrm.h @@ -0,0 +1,39 @@ +/* + * 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. + */ + +/*! + * This is the master include file for DRM Library + */ +#ifndef __SEP_DRM_H__ +#define __SEP_DRM_H__ + +#ifdef __cplusplus +extern "C" { +#endif + +#include "drm_common_api.h" +#include "wv_drm_api.h" +#include "drm_error.h" +#include "wv_mod_drm_api.h" +#include "wv_mod_oem_crypto.h" +#include "wv_mod_drm_error.h" +#include "pr_drm_api.h" + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/DRM/cc54/inc/wv_drm_api.h b/DRM/cc54/inc/wv_drm_api.h new file mode 100644 index 0000000..ff14ca9 --- /dev/null +++ b/DRM/cc54/inc/wv_drm_api.h @@ -0,0 +1,210 @@ +/* + * 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. + */ + +/*! + * NOTE: Don't include this file. It is recommended to include sepdrm.h + */ +#ifndef __WV_DRM_API_H__ +#define __WV_DRM_API_H__ + +#include <inttypes.h> +#include "drm_common_api.h" +#include "wv_fkp.h" + +/*! + * Defines + */ +#define NEW_FRAME_FLAG (1) +#define PREV_PACKET_PARTIAL_BLOCK_FLAG (1 << 1) +#define CLEAR_CONTENT_FLAG (1 << 2) + +/*! + * Structs + */ + +/* + * This structure is used to provide necessary information for Widevine audio + * ciphertext decryption. + * + * The members are: + * + * iv - AES initialization vector. + * input_ciphertext_size - Input ciphertext data size in bytes. + * p_input_ciphertext - Pointer to the input ciphertext data buffer. + * output_plaintext_size - Output plaintext data size in bytes. + * p_output_plaintext - Pointer to the output plaintext data buffer. + */ +struct drm_wv_audio_data +{ + uint8_t iv[AES_IV_COUNTER_SIZE_IN_BYTES]; + uint32_t input_ciphertext_size; + uint8_t *p_input_ciphertext; + uint32_t output_plaintext_size; + uint8_t *p_output_plaintext; +}; + + +/* + * This structure is used to provide necessary information for Widevine video + * ciphertext decryption. + * + * The members are: + * + * iv - AES initialization vector. + * input_ciphertext_size - Input ciphertext data size in bytes. + * p_input_ciphertext - Pointer to the input ciphertext data. + */ +struct drm_wv_video_cipher +{ + uint8_t iv[AES_IV_COUNTER_SIZE_IN_BYTES]; + uint32_t input_ciphertext_size; + uint8_t *p_input_ciphertext; + uint8_t flags; + uint8_t *p_output_enc_ciphertext; + uint32_t output_ciphertext_size; +}; + +struct drm_wv_nalu_headers +{ + uint32_t frame_size; + uint32_t parse_size; + uint8_t *p_enc_ciphertext; + uint32_t hdrs_buf_len; + uint8_t *p_hdrs_buf; +}; + +/*! + * Functions + */ + + +/* + * Set Widevine Asset Key + */ +uint32_t drm_wv_set_entitlementkey( + uint8_t *emm_keyptr, + uint32_t emm_keylen); + +/* + * Derive Widevine Control Word + */ +uint32_t drm_wv_derive_controlword( + uint8_t *cw_ptr, + uint32_t cw_len, + uint32_t *flags_ptr); + +/* + * Get Widevine Keybox infomation + * Retrieve the encypted kbox data and decrypt the encrypted kbox data + */ +uint32_t drm_wv_get_keyboxinfo( + uint8_t *key_data, + uint32_t *key_data_size, + uint8_t *device_id, + uint32_t *device_id_size); + + +/*! + *@brief Create a widevine session + * + */ +uint32_t drm_wv_create_session( + uint32_t *session_id); + + +/* + * @brief Creates a Widevine session for HLS content. + * @param[out] pSessionID Pointer to a variable that contains the session's ID + * number. + */ +uint32_t drm_wv_hls_create_session( + uint32_t *session_id); + +/* + * @brief Decrypts Widevine encrypted audio data + * + * @param session_id DRM Session ID number + * @param audio_info Pointer to a buffer containing Widevine audio information + * + * @return DRM_SUCCESSFUL The Widevine audio ciphertext was decrypted + */ +uint32_t drm_wv_decrypt_audio( + uint32_t session_id, + struct drm_wv_audio_data *audio_info); + + +/* + * @brief Decrypts Widevine video ciphertext data into the IMR decryption buffer + * @param session_id DRM Session ID number + * @param video_info Pointer to the Widevine video data + */ +uint32_t drm_wv_decrypt_video( + uint32_t session_id, + struct drm_wv_video_cipher *video_info); + + +uint32_t drm_wv_return_naluheaders( + uint32_t session_id, + struct drm_wv_nalu_headers *nalu_info); + +uint32_t drm_wv_keybox_provision( + struct wv_keybox *buf); + + +/* + * @brief Encrypts a Widevine keybox with a device specific key. + * + * @param[in] p_keybox Pointer to a Widevine keybox. May be NULL if + * keybox_length is zero. + * + * @param[in] keybox_length Length of the Widevine keybox in bytes. If zero then + * only the size of an encrypted Widevine keybox is returned. + * + * @param[out] p_wrapped_keybox Pointer to a buffer for the returned encrypted + * Widevine keybox. May be NULL if keybox_length is zero. + * + * @param[out] p_wrapped_keybox_length Length of the encrypted Widevine keybox + * in bytes. + * + * @param[in] p_transport_key Pointer to a transport key. May be NULL if + * transport_key_length is zero. + * + * @param[in] transport_key_length Length of the transport key in bytes. + * + * A Widevine keybox encrypted with the transport key is not supported. + */ +uint32_t drm_wv_wrap_keybox(const uint8_t * const p_keybox, + const uint32_t keybox_length, + uint8_t * const p_wrapped_keybox, + uint32_t * const p_wrapped_keybox_length, + const uint8_t * const p_transport_key, + const uint32_t transport_key_length); + + +/* + * @brief Decrypts a wrapped Widevine keybox and installs it into the device. + * + * @param[in] p_keybox Pointer to a wrapped Widevine keybox. + * + * @param[in] keybox_length Length of the Widevine keybox in bytes. + */ +uint32_t drm_wv_install_keybox(const uint8_t * const p_keybox, + const uint32_t keybox_length); + + + + +#endif //__WV_DRM_API_H__ diff --git a/DRM/cc54/inc/wv_fkp.h b/DRM/cc54/inc/wv_fkp.h new file mode 100644 index 0000000..0fa3455 --- /dev/null +++ b/DRM/cc54/inc/wv_fkp.h @@ -0,0 +1,54 @@ +/* + * 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 WV_FKP_H_ +#define WV_FKP_H_ + +#include <stdint.h> + +#define KEYBOX_DEVID_SIZE (32) // 32 bytes +#define KEYBOX_DEVKEY_SIZE (16) // 16 bytes +#define KEYBOX_KEYDATA_SIZE (72) // 72 bytes +#define KEYBOX_MAGIC_SIZE (4) // 4 bytes +#define KEYBOX_CRC_SIZE (4) // 4 bytes +#define WIDE_VINE_KEYBOX_SIZE (KEYBOX_DEVID_SIZE + \ + KEYBOX_DEVKEY_SIZE + \ + KEYBOX_KEYDATA_SIZE + \ + KEYBOX_MAGIC_SIZE + \ + KEYBOX_CRC_SIZE) + +//#define WIDEVINE_MAGIC_WORD (0x6b626f78) + +struct wv_keybox_info_length +{ + uint32_t key_data_size; // default 72 bytes + uint32_t device_id_sizee; // default 32 bytes +}; + +// +// Widevine keybox provisioning key container structure. +// +struct wv_keybox +{ + uint8_t device_id[KEYBOX_DEVID_SIZE]; // 32 bytes + uint8_t device_key[KEYBOX_DEVKEY_SIZE]; // 16 bytes + uint8_t key_data[KEYBOX_KEYDATA_SIZE]; // 72 bytes + uint8_t magic[KEYBOX_MAGIC_SIZE]; // 4 bytes + uint8_t crc[KEYBOX_CRC_SIZE]; // 4 bytes +}; + + +#endif /* WV_FKP_H_ */ diff --git a/DRM/cc54/inc/wv_mod_drm_api.h b/DRM/cc54/inc/wv_mod_drm_api.h new file mode 100644 index 0000000..c255dee --- /dev/null +++ b/DRM/cc54/inc/wv_mod_drm_api.h @@ -0,0 +1,282 @@ +/* + * 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 __WV_MOD_DRM_API_H_ +#define __WV_MOD_DRM_API_H_ + +#include <inttypes.h> +#include "drm_common_api.h" +#include "wv_mod_oem_crypto.h" + +/*! + * Defines + */ +#define DRM_WV_MOD_CLEAR_CONTENT_FLAG (1) +#define DRM_WV_MOD_AUDIO_CONTENT_FLAG (1 << 1) +#define DRM_WV_MOD_SECURE_CONTENT_FLAG (1 << 2) + +/*! + * APIs + */ +uint32_t drm_wv_mod_open_session(uint32_t *session_id); + +uint32_t drm_wv_mod_close_session(uint32_t session_id); + +uint32_t drm_wv_mod_start_playback(uint32_t session_id); + +uint32_t drm_wv_mod_stop_playback(uint32_t session_id); + +uint32_t drm_wv_mod_generate_derived_keys(uint32_t session_id, + const uint8_t *mac_key_context, + uint32_t mac_key_context_length, + const uint8_t *enc_key_context, + uint32_t enc_key_context_length); + +uint32_t drm_wv_mod_generate_nonce(uint32_t session_id, + uint32_t *nonce); + +uint32_t drm_wv_mod_generate_signature(uint32_t session_id, + const uint8_t *message, + uint32_t message_length, + uint8_t *signature, + uint32_t *signature_length); + +uint32_t drm_wv_mod_load_keys(uint32_t session_id, + const uint8_t *message, + uint32_t message_length, + const uint8_t *signature, + uint32_t signature_length, + const uint8_t *enc_mac_keys_iv, + const uint8_t *enc_mac_keys, + uint32_t num_keys, + const struct drm_wv_mod_key_object *key_array); + +uint32_t drm_wv_mod_refresh_keys(uint32_t session_id, + const uint8_t *message, + uint32_t message_length, + const uint8_t *signature, + uint32_t signature_length, + uint32_t num_keys, + const struct drm_wv_mod_key_refresh_object *key_array); + +uint32_t drm_wv_mod_select_key(uint32_t session_id, + const uint8_t *key_id, + uint32_t key_id_length); + +uint32_t drm_wv_mod_decrypt_ctr(uint32_t session_id, + const uint8_t *inp_data_buffer, + uint32_t inp_data_size, + uint8_t *out_data_buffer, + uint32_t out_data_size, + const uint8_t *iv, + uint8_t flags); + +uint32_t drm_wv_mod_rewrap_device_rsa_key(uint32_t session_id, + const uint8_t *message, + uint32_t message_length, + const uint8_t *signature, + uint32_t signature_length, + uint32_t *nonce, + const uint8_t *enc_rsa_key, + uint32_t enc_rsa_key_length, + const uint8_t *enc_rsa_key_iv, + uint8_t *wrapped_rsa_key, + uint32_t *wrapped_rsa_key_length); + +uint32_t drm_wv_mod_load_device_rsa_key(uint32_t session_id, + const uint8_t *wrapped_rsa_key, + uint32_t wrapped_rsa_key_length); + +uint32_t drm_wv_mod_generate_rsa_signature(uint32_t session_id, + const uint8_t *message, + uint32_t message_length, + uint8_t *signature, + uint32_t *signature_length); + +uint32_t drm_wv_mod_derive_keys_from_session_key(uint32_t session_id, + const uint8_t *enc_session_key, + uint32_t enc_session_key_length, + const uint8_t *mac_key_context, + uint32_t mac_key_context_length, + const uint8_t *enc_key_context, + uint32_t enc_key_context_length); + +uint32_t drm_wv_mod_generic_encrypt(uint32_t session_id, + const uint8_t *in_buffer, + uint32_t buffer_size, + const uint8_t *iv, + enum drm_wv_mod_algorithm algorithm, + uint8_t *out_buffer); + +uint32_t drm_wv_mod_generic_decrypt(uint32_t session_id, + const uint8_t *in_buffer, + uint32_t buffer_size, + const uint8_t *iv, + enum drm_wv_mod_algorithm algorithm, + uint8_t *out_buffer); + +uint32_t drm_wv_mod_generic_sign(uint32_t session_id, + const uint8_t *in_buffer, + uint32_t buffer_size, + enum drm_wv_mod_algorithm algorithm, + uint8_t *signature, + uint32_t *signature_size); + +uint32_t drm_wv_mod_generic_verify(uint32_t session_id, + const uint8_t *in_buffer, + uint32_t buffer_size, + enum drm_wv_mod_algorithm algorithm, + const uint8_t *signature, + uint32_t signature_size); + +/*! Version 9 specific APIs */ +uint32_t drm_wv_mod_v9_load_keys(uint32_t session_id, + const uint8_t *message, + uint32_t message_length, + const uint8_t *signature, + uint32_t signature_length, + const uint8_t *enc_mac_keys_iv, + const uint8_t *enc_mac_keys, + uint32_t num_keys, + const struct drm_wv_mod_key_object *key_array, + const uint8_t *pst, + uint32_t pst_length); + +uint32_t drm_wv_mod_v9_generate_rsa_signature(uint32_t session_id, + const uint8_t *message, + uint32_t message_length, + uint8_t *signature, + uint32_t *signature_length, + enum drm_wv_mod_rsa_padding_scheme padding_scheme); + + +/** + * @brief Loads an existing usage table into chaabi secure memory + * + * This should be first called prior to load keys. Caller shall call + * drm_wv_mod_update_usage_table after making this call. + * + * @param[in] usage_table_data + * Existing usage table blob to load. If NULL, chaabi will + * return required table size. + * @param[in,out] data_size + * Size of the passed-in usage_table_data, in bytes. This + * will always be updated to the required table size. + */ +uint32_t drm_wv_mod_load_usage_table(const uint8_t *const usage_table_data, + uint32_t *const data_size); + +/* @brief Update usage table and return it + * + * Chaabi will update the usage table from its TEE memory and set the flag + * is_updated. + * + * Upon returning DRM_WV_MOD_SUCCESS and is_updated == 1, caller should + * write save the usage table to the file system. + * + * @param[out] usage_table_data + * Buffer where the usage table will be returned. Input is ignored. + * This will only contain data if is_updated == 1. + * @param[in] data_size + * Size of the usage_table_data buffer, which must be large enough to + * hold the entire structure. This size can be obtained via the + * load_usage_table API or by re-using the size of a previous table blob. + * @param[out] is_updated + * Flag indicating if the table has changed since the last + * update_usage_table or load_usage_table call. + * + * TODO: Return documentation + */ +uint32_t drm_wv_mod_update_usage_table(uint8_t *const usage_table_data, + uint32_t data_size, + uint8_t *const is_updated); + +// NOTE: drm_wv_mod_update_usage_table shall be called after calling this +// function +// TODO: Documentation +uint32_t drm_wv_mod_deactivate_usage_entry(const uint8_t *const pst, + uint32_t pst_length); + +/** + * @brief Returns the usage entry information for a particular pst + * + * Caller shall call drm_wv_mod_update_usage_table after making this call. + * + * @param[in] session_id + * Session ID to be associated with the pst entry + * @param[in] pst + * Pointer to pst data used as an index into the usage table + * @param[in] pst_length + * Length of pst buffer in bytes + * @param[out] pst_report_buffer + * Pointer to caller-allocated memory where the usage report shall be placed + * @param[in,out] pst_report_buffer_length + * Length of provided pst_report_buffer in bytes. Should be sizeof(pst) + + * sizeof(struct OEMCrypto_PST_Report) in length. If extra space is provided, + * this field will reflect the actual size of the returned report. + * + * TODO: Return documentation + */ +uint32_t drm_wv_mod_report_usage(uint32_t session_id, + const uint8_t *const pst, + uint32_t pst_length, + uint8_t *const pst_report_buffer, + uint32_t *const pst_report_buffer_length); + +/** + * @brief Deletes a previously-reported entry from the usage table + * + * Caller shall call drm_wv_mod_update_usage_table after making this call. + * + * @param[in] session_id + * Session ID previously associated with the pst + * @param[in] pst + * Pointer to pst data used as an index into the usage table + * @param[in] pst_length + * Length of pst buffer in bytes + * @param[in] msg + * Pointer to message to be verified + * @param[in] msg_len + * Length of msg buffer in bytes + * @param[in] signature + * Pointer to signature to verify against + * @param[in] signature_length + * Length of signature buffer in bytes + * + * TODO: Return Documentation + */ +uint32_t drm_wv_mod_delete_usage_entry(uint32_t session_id, + const uint8_t *const pst, + uint32_t pst_length, + const uint8_t *const msg, + uint32_t msg_length, + const uint8_t *const signature, + uint32_t signature_length); + +// This will only clear Chaabi TEE memory. Caller is responsible for deleting +// usage table file from file system. +// TODO: Documentation +uint32_t drm_wv_mod_delete_usage_table(void); + +/** + * brief Clear session context + * + * This API is used to reset all sessions context. + * Typically called to cleanup sessions resulting from a application crash. + */ +uint32_t drm_wv_mod_reset_session_context(void); + +#endif /* __WV_MOD_DRM_API_H_ */ diff --git a/DRM/cc54/inc/wv_mod_drm_error.h b/DRM/cc54/inc/wv_mod_drm_error.h new file mode 100644 index 0000000..875c374 --- /dev/null +++ b/DRM/cc54/inc/wv_mod_drm_error.h @@ -0,0 +1,78 @@ +/* + * 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 __WV_MOD_DRM_ERROR_H_ +#define __WV_MOD_DRM_ERROR_H_ + +// Error codes for the modular Widevine DRM library. +enum drm_wv_mod_result +{ + DRM_WV_MOD_SUCCESS, + DRM_WV_MOD_ERROR_INIT_FAILED = 0x60000001, + DRM_WV_MOD_ERROR_TERMINATE_FAILED, + DRM_WV_MOD_ERROR_SHORT_BUFFER, + DRM_WV_MOD_ERROR_NO_DEVICE_KEY, + DRM_WV_MOD_ERROR_KEYBOX_INVALID, + DRM_WV_MOD_ERROR_NO_KEYDATA, + DRM_WV_MOD_ERROR_DECRYPT_FAILED, + DRM_WV_MOD_ERROR_WRITE_KEYBOX, + DRM_WV_MOD_ERROR_WRAP_KEYBOX, + DRM_WV_MOD_ERROR_BAD_MAGIC, + DRM_WV_MOD_ERROR_BAD_CRC, + DRM_WV_MOD_ERROR_NO_DEVICEID, + DRM_WV_MOD_ERROR_RNG_FAILED, + DRM_WV_MOD_ERROR_RNG_NOT_SUPPORTED, + DRM_WV_MOD_ERROR_OPEN_SESSION_FAILED, + DRM_WV_MOD_ERROR_CLOSE_SESSION_FAILED, // 0x10 + DRM_WV_MOD_ERROR_INVALID_SESSION, + DRM_WV_MOD_ERROR_NOT_IMPLEMENTED, + DRM_WV_MOD_ERROR_NO_CONTENT_KEY, + DRM_WV_MOD_ERROR_CONTROL_INVALID, + DRM_WV_MOD_ERROR_INVALID_CONTEXT, + DRM_WV_MOD_ERROR_SIGNATURE_FAILURE, + DRM_WV_MOD_ERROR_DEVICE_NOT_RSA_PROVISIONED, + DRM_WV_MOD_ERROR_INVALID_RSA_KEY, + DRM_WV_MOD_ERROR_INVALID_NONCE, + DRM_WV_MOD_ERROR_KEY_EXPIRED, + DRM_WV_MOD_ERROR_TOO_MANY_SESSIONS, + DRM_WV_MOD_ERROR_TOO_MANY_KEYS, + DRM_WV_MOD_ERROR_INSUFFICIENT_RESOURCES, + DRM_WV_MOD_ERROR_INSUFFICIENT_HDCP, + DRM_WV_MOD_ERROR_UNKNOWN_FAILURE, + DRM_WV_MOD_ERROR_UNSUPPORTED, // 0x20 + DRM_WV_MOD_ERROR_ILLEGAL_PARAMETER, + DRM_WV_MOD_ERROR_SEP_DRIVER_OPERATION_FAILED, + DRM_WV_MOD_ENCRYPTION_DECRYPTION_SIZE_INCORRECT, + DRM_WV_MOD_ERROR_BUFFER_TOO_SMALL, + DRM_WV_MOD_ERROR_BUFFER_TYPE_INVALID, + DRM_WV_MOD_ERROR_DATA_SIZE_TOO_LARGE, + DRM_WV_MOD_ERROR_RETURN_BUFFER_TOO_SMALL, + DRM_WV_MOD_ERROR_DMA_DATA_SIZE_TOO_LARGE, + DRM_WV_MOD_ERROR_NONCE_GENERATION_FAILURE, + DRM_WV_MOD_ERROR_SESSION_NALU_PARSE_FAILURE, + DRM_WV_MOD_ERROR_CRYPTO_OP_FAILURE, + DRM_WV_MOD_ERROR_DERIVED_ENCRYPTION_KEY_FAILED, + DRM_WV_MOD_ERROR_DERIVED_CLIENT_MAC_KEY_FAILED, + DRM_WV_MOD_ERROR_DERIVED_SERVER_MAC_KEY_FAILED, + DRM_WV_MOD_ERROR_KEY_DERIVATION_FAILED, + DRM_WV_MOD_ERROR_INVALID_DATA_FORMAT_VERSION, + DRM_WV_MOD_ERROR_INVALID_PLAYBACK_STATE, + DRM_WV_MOD_ERROR_INVALID_SESSION_STATE, + DRM_WV_MOD_ERROR_INVALID_USAGE_TABLE_GENERATION_NUM, + DRM_WV_MOD_ERROR_INVALID_USAGE_TABLE_MAGIC +}; + +#endif diff --git a/DRM/cc54/inc/wv_mod_oem_crypto.h b/DRM/cc54/inc/wv_mod_oem_crypto.h new file mode 100644 index 0000000..d43cc99 --- /dev/null +++ b/DRM/cc54/inc/wv_mod_oem_crypto.h @@ -0,0 +1,54 @@ +/* + * 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 __WV_MOD_OEM_CRYPTO_H_ +#define __WV_MOD_OEM_CRYPTO_H_ + +#include <inttypes.h> + +enum drm_wv_mod_algorithm +{ + DRM_WV_MOD_AES_CBC_128_NO_PADDING = 0, + HMAC_SHA256 +}; + +enum drm_wv_mod_rsa_padding_scheme +{ + DRM_WV_MOD_RSA_PADDING_SCHEME_RSASSA_PSS_SHA1 = 1, + DRM_WV_MOD_RSA_PADDING_SCHEME_RSASSA_PKCS1v15, + DRM_WV_MOD_RSA_PADDING_SCHEME_MAX_VALUE +}; + +struct drm_wv_mod_key_object +{ + const uint8_t *key_id; + uint32_t key_id_len; + const uint8_t *key_data_iv; + const uint8_t *key_data; + uint32_t key_data_length; + const uint8_t *key_control_iv; + const uint8_t *key_control; +}; + +struct drm_wv_mod_key_refresh_object +{ + const uint8_t *key_id; + uint32_t key_id_len; + const uint8_t *key_control_iv; + const uint8_t *key_control; +}; + +#endif /* __WV_MOD_OEM_CRYPTO_H_ */ diff --git a/libmediaparser/mixvbp/vbp_manager/include/vbp_loader.h b/libmediaparser/mixvbp/vbp_manager/include/vbp_loader.h new file mode 100644 index 0000000..b66faea --- /dev/null +++ b/libmediaparser/mixvbp/vbp_manager/include/vbp_loader.h @@ -0,0 +1,475 @@ +/* + * 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 VBP_LOADER_H +#define VBP_LOADER_H + +#include <va/va.h> + +#ifdef USE_HW_VP8 +#include <va/va_dec_vp8.h> +#endif + +#ifndef TRUE +#define TRUE 1 +#endif + +#ifndef FALSE +#define FALSE 0 +#endif + + +#ifndef uint8 +typedef unsigned char uint8; +#endif +#ifndef uint16 +typedef unsigned short uint16; +#endif +#ifndef uint32 +typedef unsigned int uint32; +#endif +#ifndef int16 +typedef short int16; +#endif + +typedef void *Handle; + +/* + * MPEG-4 Part 2 data structure + */ + +typedef struct _vbp_codec_data_mp42 +{ + uint8 profile_and_level_indication; + uint32 video_object_layer_width; + uint32 video_object_layer_height; + + // 0 for unspecified, PAL/NTSC/SECAM + uint8 video_format; + + // 0 short range, 1 full range + uint8 video_range; + + // default 2 (unspecified), 1 for BT709. + uint8 matrix_coefficients; + + uint8 short_video_header; + + // always exist for mpeg-4, + uint8 aspect_ratio_info; + uint8 par_width; + uint8 par_height; + + // bit rate + int bit_rate; +} vbp_codec_data_mp42; + +typedef struct _vbp_slice_data_mp42 +{ + uint8* buffer_addr; + uint32 slice_offset; + uint32 slice_size; + VASliceParameterBufferMPEG4 slice_param; +} vbp_slice_data_mp42; + +typedef struct _vbp_picture_data_mp42 vbp_picture_data_mp42; + +struct _vbp_picture_data_mp42 +{ + uint8 vop_coded; + uint16 vop_time_increment; + /* indicates if current buffer contains parameter for the first slice of the picture */ + uint8 new_picture_flag; + VAPictureParameterBufferMPEG4 picture_param; + vbp_slice_data_mp42 slice_data; + + vbp_picture_data_mp42* next_picture_data; +}; + +typedef struct _vbp_data_mp42 +{ + vbp_codec_data_mp42 codec_data; + VAIQMatrixBufferMPEG4 iq_matrix_buffer; + + uint32 number_picture_data; + uint32 number_pictures; + + vbp_picture_data_mp42 *picture_data; + +} vbp_data_mp42; + +/* + * H.264 data structure + */ + +typedef struct _vbp_codec_data_h264 +{ + uint8 pic_parameter_set_id; + uint8 seq_parameter_set_id; + + uint8 profile_idc; + uint8 level_idc; + /*constraint flag sets (h.264 Spec v2009)*/ + uint8 constraint_set0_flag; + uint8 constraint_set1_flag; + uint8 constraint_set2_flag; + uint8 constraint_set3_flag; + uint8 constraint_set4_flag; + + uint8 num_ref_frames; + uint8 gaps_in_frame_num_value_allowed_flag; + + uint8 frame_mbs_only_flag; + uint8 mb_adaptive_frame_field_flag; + + int frame_width; + int frame_height; + + uint8 vui_parameters_present_flag; + + /* aspect ratio */ + uint8 aspect_ratio_idc; + uint16 sar_width; + uint16 sar_height; + + /* cropping information */ + int crop_top; + int crop_bottom; + int crop_left; + int crop_right; + + /* video fromat */ + + // default 5 unspecified + uint8 video_format; + uint8 video_full_range_flag; + + // default 2 unspecified + uint8 matrix_coefficients; + + uint8 pic_order_cnt_type; + int log2_max_pic_order_cnt_lsb_minus4; + + int bit_rate; + + int has_slice; +} vbp_codec_data_h264; + +typedef struct _vbp_slice_data_h264 +{ + uint8* buffer_addr; + + uint32 slice_offset; /* slice data offset */ + + uint32 slice_size; /* slice data size */ + + uint8 nal_unit_type; + + VASliceParameterBufferH264 slc_parms; + +} vbp_slice_data_h264; + + +typedef struct _vbp_picture_data_h264 +{ + VAPictureParameterBufferH264* pic_parms; + + uint32 num_slices; + + vbp_slice_data_h264* slc_data; + +} vbp_picture_data_h264; + + +typedef struct _vbp_data_h264 +{ + /* rolling counter of buffers sent by vbp_parse */ + uint32 buf_number; + + uint32 num_pictures; + + /* if SPS has been received */ + uint8 has_sps; + + /* if PPS has been received */ + uint8 has_pps; + + uint8 new_sps; + + uint8 new_pps; + + vbp_picture_data_h264* pic_data; + + /** + * do we need to send matrix to VA for each picture? If not, we need + * a flag indicating whether it is updated. + */ + VAIQMatrixBufferH264* IQ_matrix_buf; + + vbp_codec_data_h264* codec_data; + +#ifdef USE_SLICE_HEADER_PARSING + VAParsePictureParameterBuffer* pic_parse_buffer; +#endif + +} vbp_data_h264; + +/* + * vc1 data structure + */ +typedef struct _vbp_codec_data_vc1 +{ + /* Sequence layer. */ + uint8 PROFILE; + uint8 LEVEL; + uint8 POSTPROCFLAG; + uint8 PULLDOWN; + uint8 INTERLACE; + uint8 TFCNTRFLAG; + uint8 FINTERPFLAG; + uint8 PSF; + + // default 2: unspecified + uint8 MATRIX_COEF; + + /* Entry point layer. */ + uint8 BROKEN_LINK; + uint8 CLOSED_ENTRY; + uint8 PANSCAN_FLAG; + uint8 REFDIST_FLAG; + uint8 LOOPFILTER; + uint8 FASTUVMC; + uint8 EXTENDED_MV; + uint8 DQUANT; + uint8 VSTRANSFORM; + uint8 OVERLAP; + uint8 QUANTIZER; + uint16 CODED_WIDTH; + uint16 CODED_HEIGHT; + uint8 EXTENDED_DMV; + uint8 RANGE_MAPY_FLAG; + uint8 RANGE_MAPY; + uint8 RANGE_MAPUV_FLAG; + uint8 RANGE_MAPUV; + + /* Others. */ + uint8 RANGERED; + uint8 MAXBFRAMES; + uint8 MULTIRES; + uint8 SYNCMARKER; + uint8 RNDCTRL; + uint8 REFDIST; + uint16 widthMB; + uint16 heightMB; + + uint8 INTCOMPFIELD; + uint8 LUMSCALE2; + uint8 LUMSHIFT2; + + // aspect ratio + + // default unspecified + uint8 ASPECT_RATIO; + + uint8 ASPECT_HORIZ_SIZE; + uint8 ASPECT_VERT_SIZE; + // bit rate + int bit_rate; +} vbp_codec_data_vc1; + +typedef struct _vbp_slice_data_vc1 +{ + uint8 *buffer_addr; + uint32 slice_offset; + uint32 slice_size; + VASliceParameterBufferVC1 slc_parms; /* pointer to slice parms */ +} vbp_slice_data_vc1; + + +typedef struct _vbp_picture_data_vc1 +{ + uint32 picture_is_skipped; /* VC1_PTYPE_SKIPPED is PTYPE is skipped. */ + VAPictureParameterBufferVC1 *pic_parms; /* current parsed picture header */ + uint32 size_bitplanes; /* based on number of MBs */ + uint8 *packed_bitplanes; /* contains up to three bitplanes packed for libVA */ + uint32 num_slices; /* number of slices. always at least one */ + vbp_slice_data_vc1 *slc_data; /* pointer to array of slice data */ +} vbp_picture_data_vc1; + +typedef struct _vbp_data_vc1 +{ + uint32 buf_number; /* rolling counter of buffers sent by vbp_parse */ + vbp_codec_data_vc1 *se_data; /* parsed SH/EPs */ + + uint32 num_pictures; + + vbp_picture_data_vc1* pic_data; +} vbp_data_vc1; + +#ifdef USE_HW_VP8 +typedef struct _vbp_codec_data_vp8 +{ + uint8 frame_type; + uint8 version_num; + int show_frame; + + uint32 frame_width; + uint32 frame_height; + + int refresh_alt_frame; + int refresh_golden_frame; + int refresh_last_frame; + + /* cropping information */ + int crop_top; + int crop_bottom; + int crop_left; + int crop_right; + + int golden_copied; + int altref_copied; +} vbp_codec_data_vp8; + +typedef struct _vbp_slice_data_vp8 +{ + uint8 *buffer_addr; + uint32 slice_offset; + uint32 slice_size; + VASliceParameterBufferVP8 slc_parms; /* pointer to slice parms */ +} vbp_slice_data_vp8; + +typedef struct _vbp_picture_data_vp8 +{ + VAPictureParameterBufferVP8* pic_parms; /* current parsed picture header */ + + uint32 num_slices; /* number of slices. always one for VP8 */ + vbp_slice_data_vp8 *slc_data; /* pointer to array of slice data */ +} vbp_picture_data_vp8; + +typedef struct _vbp_data_vp8 +{ + uint32 buf_number; /* rolling counter of buffers sent by vbp_parse */ + vbp_codec_data_vp8 *codec_data; + + uint32 num_pictures; + + vbp_picture_data_vp8* pic_data; + + VAProbabilityDataBufferVP8* prob_data; + VAIQMatrixBufferVP8* IQ_matrix_buf; +} vbp_data_vp8; +#endif + +enum _picture_type +{ + VC1_PTYPE_I, + VC1_PTYPE_P, + VC1_PTYPE_B, + VC1_PTYPE_BI, + VC1_PTYPE_SKIPPED +}; + +enum _vbp_parser_error +{ + VBP_OK, + VBP_TYPE, + VBP_LOAD, + VBP_INIT, + VBP_DATA, + VBP_DONE, + VBP_MEM, + VBP_PARM, + VBP_PARTIAL, + VBP_MULTI, + VBP_ERROR +}; + +enum _vbp_parser_type +{ + VBP_VC1, + VBP_MPEG2, + VBP_MPEG4, + VBP_H264, +#ifdef USE_HW_VP8 + VBP_VP8, +#endif +#if (defined USE_AVC_SHORT_FORMAT || defined USE_SLICE_HEADER_PARSING) + VBP_H264SECURE, +#endif +}; + + +/* + * open video bitstream parser to parse a specific media type. + * @param parser_type: one of the types defined in #vbp_parser_type + * @param hcontext: pointer to hold returned VBP context handle. + * @return VBP_OK on success, anything else on failure. + * + */ +uint32 vbp_open(uint32 parser_type, Handle *hcontext); + +/* + * close video bitstream parser. + * @param hcontext: VBP context handle. + * @returns VBP_OK on success, anything else on failure. + * + */ +uint32 vbp_close(Handle hcontext); + +/* + * parse bitstream. + * @param hcontext: handle to VBP context. + * @param data: pointer to bitstream buffer. + * @param size: size of bitstream buffer. + * @param init_flag: 1 if buffer contains bitstream configuration data, 0 otherwise. + * @return VBP_OK on success, anything else on failure. + * + */ +uint32 vbp_parse(Handle hcontext, uint8 *data, uint32 size, uint8 init_data_flag); + +/* + * query parsing result. + * @param hcontext: handle to VBP context. + * @param data: pointer to hold a data blob that contains parsing result. + * Structure of data blob is determined by the media type. + * @return VBP_OK on success, anything else on failure. + * + */ +uint32 vbp_query(Handle hcontext, void **data); + + +/* + * flush any un-parsed bitstream. + * @param hcontext: handle to VBP context. + * @returns VBP_OK on success, anything else on failure. + * + */ +uint32 vbp_flush(Handle hcontent); + +#if (defined USE_AVC_SHORT_FORMAT || defined USE_SLICE_HEADER_PARSING) +/* + * update the the vbp context using the new data + * @param hcontext: handle to VBP context. + * @param data: pointer to the new data buffer. + * @param size: size of new data buffer. + * @param data: pointer to hold a data blob that contains parsing result. + * @returns VBP_OK on success, anything else on failure. + * +*/ +uint32 vbp_update(Handle hcontext, void *newdata, uint32 size, void **data); +#endif + +#endif /* VBP_LOADER_H */ |