Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0
0002 /*
0003  * cxd2880_common.c
0004  * Sony CXD2880 DVB-T2/T tuner + demodulator driver
0005  * common functions
0006  *
0007  * Copyright (C) 2016, 2017, 2018 Sony Semiconductor Solutions Corporation
0008  */
0009 
0010 #include "cxd2880_common.h"
0011 
0012 int cxd2880_convert2s_complement(u32 value, u32 bitlen)
0013 {
0014     if (!bitlen || bitlen >= 32)
0015         return (int)value;
0016 
0017     if (value & (u32)(1 << (bitlen - 1)))
0018         return (int)(GENMASK(31, bitlen) | value);
0019     else
0020         return (int)(GENMASK(bitlen - 1, 0) & value);
0021 }