1 // SPDX-License-Identifier: GPL-2.0 2 /* 3 * Support for Intel Camera Imaging ISP subsystem. 4 * Copyright (c) 2015, Intel Corporation. 5 */ 6 7 #include "tag.h" 8 #include <platform_support.h> /* NULL */ 9 #include <assert_support.h> 10 #include "tag_local.h" 11 12 /* 13 * @brief Creates the tag description from the given parameters. 14 * @param[in] num_captures 15 * @param[in] skip 16 * @param[in] offset 17 * @param[out] tag_descr 18 */ 19 void sh_css_create_tag_descr(int num_captures,unsigned int skip,int offset,unsigned int exp_id,struct sh_css_tag_descr * tag_descr)20sh_css_create_tag_descr(int num_captures, 21 unsigned int skip, 22 int offset, 23 unsigned int exp_id, 24 struct sh_css_tag_descr *tag_descr) 25 { 26 assert(tag_descr); 27 28 tag_descr->num_captures = num_captures; 29 tag_descr->skip = skip; 30 tag_descr->offset = offset; 31 tag_descr->exp_id = exp_id; 32 } 33 34 /* 35 * @brief Encodes the members of tag description into a 32-bit value. 36 * @param[in] tag Pointer to the tag description 37 * @return (unsigned int) Encoded 32-bit tag-info 38 */ 39 unsigned int sh_css_encode_tag_descr(struct sh_css_tag_descr * tag)40sh_css_encode_tag_descr(struct sh_css_tag_descr *tag) 41 { 42 int num_captures; 43 unsigned int num_captures_sign; 44 unsigned int skip; 45 int offset; 46 unsigned int offset_sign; 47 unsigned int exp_id; 48 unsigned int encoded_tag; 49 50 assert(tag); 51 52 if (tag->num_captures < 0) { 53 num_captures = -tag->num_captures; 54 num_captures_sign = 1; 55 } else { 56 num_captures = tag->num_captures; 57 num_captures_sign = 0; 58 } 59 skip = tag->skip; 60 if (tag->offset < 0) { 61 offset = -tag->offset; 62 offset_sign = 1; 63 } else { 64 offset = tag->offset; 65 offset_sign = 0; 66 } 67 exp_id = tag->exp_id; 68 69 if (exp_id != 0) { 70 /* we encode either an exp_id or capture data */ 71 assert((num_captures == 0) && (skip == 0) && (offset == 0)); 72 73 encoded_tag = TAG_EXP | (exp_id & 0xFF) << TAG_EXP_ID_SHIFT; 74 } else { 75 encoded_tag = TAG_CAP 76 | ((num_captures_sign & 0x00000001) << TAG_NUM_CAPTURES_SIGN_SHIFT) 77 | ((offset_sign & 0x00000001) << TAG_OFFSET_SIGN_SHIFT) 78 | ((num_captures & 0x000000FF) << TAG_NUM_CAPTURES_SHIFT) 79 | ((skip & 0x000000FF) << TAG_OFFSET_SHIFT) 80 | ((offset & 0x000000FF) << TAG_SKIP_SHIFT); 81 } 82 return encoded_tag; 83 } 84