cxd2880_common.c 493 B

123456789101112131415161718192021
  1. // SPDX-License-Identifier: GPL-2.0
  2. /*
  3. * cxd2880_common.c
  4. * Sony CXD2880 DVB-T2/T tuner + demodulator driver
  5. * common functions
  6. *
  7. * Copyright (C) 2016, 2017, 2018 Sony Semiconductor Solutions Corporation
  8. */
  9. #include "cxd2880_common.h"
  10. int cxd2880_convert2s_complement(u32 value, u32 bitlen)
  11. {
  12. if (!bitlen || bitlen >= 32)
  13. return (int)value;
  14. if (value & (u32)(1 << (bitlen - 1)))
  15. return (int)(GENMASK(31, bitlen) | value);
  16. else
  17. return (int)(GENMASK(bitlen - 1, 0) & value);
  18. }